React - Js Web Development
React - Js Web Development
LTD
IT SERVICES & IT CONSULTING
8-7-7/2, Plot NO.51, Opp: Naveena School, Hasthinapuram Central, Hyderabad , 500 079. Telangana
3: React Basics
Create React App or Vite setup
JSX & Components
Props & State
Conditional rendering
Event handling
Lists and keys
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
VS Code Setup
Visual Studio Code is the most popular code editor. You’ll set it up with essential
extensions like Prettier, ESLint, and live server, optimizing your workflow from the
start.
Outcome: By the end of this unit, you'll be able to build, style, and deploy basic web
pages, understand core programming logic, and use tools that professional
developers rely on daily.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. Forms in HTML5
HTML5 greatly improved forms by introducing new input types, attributes, and
validation features. Forms are used to collect user input, like login credentials,
contact information, or search queries.
Basic form structure:
<form action="/submit" method="post">
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>
</form>
New attributes:
placeholder – Hint text inside an input
required – Makes an input mandatory
pattern – RegEx pattern for custom validation
autofocus, autocomplete, min, max, step
Built-in validation: HTML5 allows basic client-side form validation without
JavaScript. For example, an email field with required will not allow form submission
until a valid email is entered.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. Media in HTML5
Before HTML5, embedding video and audio required plugins like Flash. HTML5
introduced native support for multimedia with the <video> and <audio> elements.
Video Example:
<video width="600" controls>
<source src="video.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>
Audio Example:
<audio controls>
<source src="audio.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Common attributes:
controls – Adds playback controls
autoplay – Starts playing automatically
loop – Repeats the media after it ends
muted – Starts media without sound
poster – Specifies an image to show before the video plays
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. CSS Grid
Grid is a two-dimensional layout system that enables you to design complex layouts
using rows and columns.
Basic setup:
.grid-container {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: auto auto;
gap: 20px;
}
grid-template-columns and grid-template-rows define the layout structure.
fr stands for fraction of available space.
gap sets spacing between grid items.
You can place items using grid-column and grid-row.
Grid is perfect for entire page layouts, image galleries, admin dashboards, and
anywhere you need both horizontal and vertical structure.
4. Media Queries
Media queries are used to create responsive designs. They apply CSS rules only when
certain conditions are met—like screen width, orientation, or resolution.
Example:
@media (max-width: 768px) {
.container {
flex-direction: column;
}
}
This code will stack a Flexbox container’s items vertically on devices with screens
narrower than 768px.
Common breakpoints:
Mobile: max-width: 600px
Tablet: 600px–1024px
Desktop: 1024px and up
Media queries are essential for ensuring your site looks great on phones, tablets, and
desktops.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
alert("Button clicked!");
});
You can use JavaScript to dynamically create elements, delete them, change
attributes, and respond to user input—this is how interactive forms, animations, and
pop-ups work.
Conclusion
Mastering modern JavaScript (ES6+) gives you the tools to build responsive, data-
driven applications. Variables hold data, functions perform actions, arrays manage
collections, objects organize complex information, and the DOM allows you to bring
it all to life in the browser. Together, these concepts form the foundation of
everything you’ll do in web development—especially when you move on to
frameworks like React.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Learning Git and GitHub is critical for professional development. Git helps you
manage your code history, while GitHub enables real-time collaboration with others.
With just a few commands, you can track your progress, back up your code, and
contribute to projects with confidence—skills that every modern developer must
have.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. Extensions
VS Code’s real power comes from its extensions. These small tools enhance
functionality for different programming languages and frameworks.
Here are some must-have extensions for web development:
✅ ESLint
Automatically detects and fixes JavaScript/TypeScript code style issues.
Helps maintain consistent code quality across teams.
✅ Prettier – Code Formatter
Auto-formats your code on save.
Supports many languages including JavaScript, HTML, and CSS.
✅ Live Server
Launches a local development server with live reload.
Great for testing HTML/CSS/JS projects in real time.
✅ JavaScript (ES6) Code Snippets
Provides code snippets for common JavaScript patterns and syntax.
Speeds up writing modern JavaScript code.
✅ React Developer Tools (optional)
Helps with React-specific workflows.
Adds snippets and syntax highlighting for JSX and React features.
✅ GitLens
Enhances built-in Git support with blame annotations, history browsing, and
more.
✅ Auto Rename Tag
Automatically renames paired HTML/XML tags when you change one.
✅ Bracket Pair Colorizer 2
Colors matching brackets in the same color for better readability of nested code.
✅ Path Intellisense
Auto-completes filenames and paths as you type in import statements.
✅ Debugger for Chrome
Lets you debug JavaScript code directly in VS Code with Google Chrome
integration.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
4. Workspace Setup
To organize your work:
Open a folder/project via File > Open Folder.
Create files like index.html, style.css, and script.js inside the folder.
Save your workspace (File > Save Workspace As) if you're working on multiple
projects.
You can also create .vscode folders to store workspace-specific settings (e.g.,
formatter preferences).
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
6. Array Methods
Methods like .map(), .filter(), and .reduce() are used frequently in React to
manipulate data and render lists.
const items = data.map(item => <li>{item}</li>);
7. Modules and Import/Export
React relies on ES6 modules to organize code:
import React from "react";
export const Button = () => <button>Click</button>;
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
✅ const
The const keyword is used to declare constant values—that is, variables that cannot
be reassigned after their initial declaration. Like let, it is also block-scoped.
Example:
const name = "Alice";
// name = "Bob"; // Error: Assignment to constant variable
However, it's important to note that if the variable holds an object or array, the
contents of that object or array can still be changed.
Example:
const person = { age: 25 };
person.age = 26; // This is allowed
Best Practice: Use const by default and only use let when you know the variable's
value will change.
Arrow Functions
Arrow functions offer a concise and clean way to write functions in JavaScript. They
are especially useful for short, one-line functions or for cases where you want to
maintain the surrounding context of this.
✅ Syntax
Traditional function:
function greet(name) {
return "Hello, " + name;
}
Arrow function:
const greet = (name) => "Hello, " + name;
If the function takes only one parameter, the parentheses can be omitted:
const double = x => x * 2;
If the function body has multiple lines, curly braces and an explicit return are
needed:
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Use Case:
Use filter() when you want to exclude or select specific items based on a condition—
for example, filtering out inactive users from a list or displaying only products under
a certain price.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Objects
const obj1 = { a: 1, b: 2 };
const obj2 = { ...obj1, c: 3 };
console.log(obj2); // { a: 1, b: 2, c: 3 }
This is useful for shallow cloning or merging objects.
Rest Operator (...)
The rest operator collects multiple elements into a single array or object. It’s
essentially the opposite of spread and is used in destructuring.
Array Rest
const [first, ...rest] = [1, 2, 3, 4];
console.log(rest); // [2, 3, 4]
Object Rest
const { a, ...others } = { a: 1, b: 2, c: 3 };
console.log(others); // { b: 2, c: 3 }
Function Parameters
function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}
console.log(sum(1, 2, 3)); // 6
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Destructuring simplifies accessing data from arrays and objects, the spread operator
expands data into its elements, and the rest operator gathers elements into a group.
Together, they offer concise syntax and greater flexibility, especially when working
with complex data structures, function parameters, and immutable state updates in
frameworks like React. Understanding and using them effectively leads to cleaner,
more maintainable JavaScript code.
1. Promises
A Promise is an object that represents the eventual completion (or failure) of an
asynchronous operation and its resulting value. It can be in one of three states:
Pending – the operation is still ongoing.
Fulfilled – the operation completed successfully.
Rejected – the operation failed.
Creating a Promise
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'New Post', body: 'Hello world!' })
})
.then(response => response.json())
.then(data => console.log(data));
3. Async/Await
async/await is syntactic sugar built on top of Promises. It allows you to write
asynchronous code that looks and behaves like synchronous code, making it much
easier to read and maintain.
Using async and await
async function getData() {
try {
const response = await fetch('https://jsonplaceholder.typicode.com/posts/1');
const data = await response.json();
console.log(data);
} catch (error) {
console.error('Error:', error);
}
}
getData();
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Promises, fetch, and async/await are essential tools in JavaScript for dealing with
asynchronous tasks. Promises offer a structured way to handle operations over time.
fetch makes HTTP requests straightforward, and async/await makes asynchronous
code much easier to write and understand. Mastering these concepts is key to writing
modern, efficient JavaScript applications.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
module.exports = {
entry: './src/index.js',
output: {
filename: 'bundle.js',
path: __dirname + '/dist'
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] }
]
}
};
Webpack can be complex, but it’s highly customizable and works well for large-scale
applications.
Vite (Overview)
Vite is a modern build tool that’s faster and simpler than Webpack for many use
cases. It was created by Evan You (the creator of Vue.js).
Key Features:
Lightning-fast dev server using native ES modules.
Instant hot module replacement (HMR) for real-time feedback during
development.
Minimal configuration out of the box.
Uses Rollup under the hood for production builds.
Vite Setup Example
npm create vite@latest my-app
cd my-app
npm install
npm run dev
Vite is ideal for small to medium projects or developers who want a quick setup with
modern features.
Modules and bundlers are essential tools in modern JavaScript. Modules help
organize and reuse code, while bundlers like Webpack and Vite prepare that code for
the browser. Webpack is powerful and flexible for large-scale apps, while Vite offers
speed and simplicity for fast development. Understanding both helps you choose the
right tool for your project.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3: React Basics
React is a popular JavaScript library developed by Facebook for building user
interfaces, especially for single-page applications (SPAs). It helps developers create
reusable UI components that efficiently update and render when data changes.
1. Components
In React, everything is built using components. A component is a JavaScript function
that returns JSX (a syntax extension that looks like HTML).
function Greeting() {
return <h1>Hello, world!</h1>;
}
2. JSX
JSX stands for JavaScript XML. It allows you to write HTML-like syntax inside
JavaScript, making the structure of the UI more readable.
const element = <h1>Welcome!</h1>;
Under the hood, JSX gets compiled into React.createElement() calls.
3. Props
Props (short for "properties") are how data is passed from parent to child
components.
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
You use it like this:
<Welcome name="Alice" />
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
4. State
State allows components to manage internal data that can change over time.
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
);
}
5. React Rendering
React uses a virtual DOM to update the UI efficiently. When state or props change,
React re-renders only the necessary parts of the DOM.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Cons of Vite:
Slightly smaller ecosystem compared to CRA (but growing fast)
Not “official” from the React team (though fully compatible)
Performance Comparison
Development Speed: Vite is significantly faster. It only compiles what’s needed
on-demand, while CRA rebuilds the entire app with every change.
Production Build: Both produce optimized bundles, though Vite’s use of Rollup
can result in smaller outputs in some cases.
Which Should You Choose?
Choose CRA if:
You want a standard, time-tested setup.
You prefer sticking with official React tooling.
Your team is already familiar with Webpack.
Choose Vite if:
You want faster development experience.
You prefer modern tooling and faster hot reloads.
You value simplicity and quick setup.
Both CRA and Vite are excellent tools for setting up React apps. CRA is great for
traditional setups and offers strong community support, while Vite is a lightweight,
modern alternative with impressive speed and simplicity. For most new projects in
2024 and beyond, Vite is becoming the preferred choice thanks to its performance
and ease of use.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Why JSX?
It makes code more readable and expressive.
It allows mixing markup (HTML-like) and logic (JavaScript) in one place.
Developers can embed JavaScript expressions inside JSX using {}.
Example with JavaScript inside JSX:
const name = "Alice";
const greeting = <h1>Hello, {name}!</h1>;
You can also use conditional rendering:
const isLoggedIn = true;
const message = <p>{isLoggedIn ? "Welcome back!" : "Please sign in."}</p>;
2. What Are Components?
Components are the building blocks of a React application. Each component is a
piece of the UI that is reusable and independent. React apps are made by combining
multiple components together.
There are two main types of components:
Functional Components
Class Components (less common in modern React)
Functional Components
These are simple JavaScript functions that return JSX.
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
You can use this component like this:
<Welcome name="Alice" />
Here, props (short for "properties") are inputs passed to the component from its
parent.
Class Components (Older Style)
Though functional components are more common now (especially with hooks),
here’s how a class component looks:
class Welcome extends React.Component {
render() {
return <h1>Hello, {this.props.name}</h1>;
}
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Component Composition
Components can be composed of other components to build complex UIs.
function App() {
return (
<div>
<Header />
<Welcome name="Alice" />
<Footer />
</div>
);
}
This makes the UI modular, clean, and easy to manage.
JSX and components are central to React. JSX allows you to write expressive, HTML-
like code inside JavaScript, while components let you break your UI into manageable,
reusable pieces. Functional components, especially with hooks, are the modern
standard in React. Mastering these concepts is the first step toward building
powerful, scalable front-end applications with React.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
// Usage
<Welcome name="Alice" />
In this example, the name prop is passed to the Welcome component. Inside the
component, props.name is used to display a personalized message.
Key Features of Props:
Passed down from parent to child.
Immutable (cannot be changed by the child).
Allow components to be reusable and customizable.
Props can be of any type — string, number, array, object, or even functions (used in
event handling or callbacks).
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
What Is State?
State is data that is managed within a component. It can change over time, usually in
response to user actions or other events, and when it does, React re-renders the
component to reflect those changes.
In modern React, state is managed using the useState hook in functional
components.
Example:
import { useState } from 'react';
function Counter() {
const [count, setCount] = useState(0);
return (
<div>
<p>You clicked {count} times</p>
<button onClick={() => setCount(count + 1)}>Click me</button>
</div>
);
}
count is the current state.
setCount is the function to update it.
Calling setCount() triggers a re-render with the updated value.
Conditional Rendering
Conditional rendering in React means showing or hiding parts of the user interface
(UI) based on certain conditions — like user input, app state, or data. Just like regular
JavaScript, React lets you control what’s rendered on the screen using if statements,
ternary operators, logical operators, and more.
This technique is essential for building dynamic UIs where the interface responds to
the app’s logic or user behavior.
1. Using If-Else Statements
The most straightforward way to conditionally render elements is by using
JavaScript’s if-else statements before the return statement in your component.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function Greeting(props) {
const isLoggedIn = props.isLoggedIn;
if (isLoggedIn) {
return <h1>Welcome back!</h1>;
} else {
return <h1>Please sign in.</h1>;
}
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
return (
<div>
{button}
</div>
);
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Event Handling
Event handling in React is how you respond to user interactions — like clicking a
button, typing in an input, or submitting a form. It works similarly to event handling
in plain JavaScript but with a few important differences due to JSX and the React
component system.
React provides a synthetic event system, which wraps the native browser events to
ensure consistency across different browsers. These synthetic events are accessible
through the SyntheticEvent object in React.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. Synthetic Events
React wraps native browser events with its own event system, known as
SyntheticEvent. This helps React normalize events across browsers and add extra
functionality.
You still have access to native event properties like event.target,
event.preventDefault(), and event.stopPropagation().
Example:
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function Form() {
function handleSubmit(event) {
event.preventDefault();
console.log('Form submitted!');
}
return (
<form onSubmit={handleSubmit}>
<button type="submit">Submit</button>
</form>
);
}
Here, event.preventDefault() stops the form from reloading the page.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
handleClick() {
console.log('Clicked!');
}
render() {
return <button onClick={this.handleClick}>Click</button>;
}
}
This ensures the this keyword points to the component instance
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function FruitList() {
return (
<ul>
{fruits.map((fruit, index) => (
<li key={index}>{fruit}</li>
))}
</ul>
);
}
fruits.map() loops through the array.
Each item is returned as a <li> element.
key is added to help React identify each list item.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function UserList() {
return (
<ul>
{users.map(user => (
<li key={user.id}>{user.name}</li>
))}
</ul>
);
}
Avoid using array indexes as keys if the order of items might change. Using indexes
can lead to rendering bugs when React incorrectly associates components with
previous data.
function CategoryList() {
return (
<div>
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
{categories.map((category) => (
<div key={category.name}>
<h3>{category.name}</h3>
<ul>
{category.items.map(item => (
<li key={item}>{item}</li>
))}
</ul>
</div>
))}
</div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function App() {
return (
<ThemeContext.Provider value="dark">
<Toolbar />
</ThemeContext.Provider>
);
}
Child components can access the context using useContext.
3. Refs
Refs provide a way to access DOM elements or persist values across renders without
causing re-renders.
const inputRef = useRef();
<input ref={inputRef} />
Useful for focusing inputs, controlling animations, or storing previous state.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
1. useEffect
useEffect lets you perform side effects in function components — like fetching data,
updating the DOM, setting timers, or subscribing to events.
Syntax:
useEffect(() => {
// side effect logic
return () => {
// cleanup logic (optional)
};
}, [dependencies]);
Runs after the component mounts and after updates.
Accepts a dependency array to control when it runs.
Optional cleanup function runs before the effect re-runs or when the component
unmounts.
Example:
useEffect(() => {
document.title = `Clicked ${count} times`;
}, [count]);
This effect updates the document title whenever count changes.
2. useRef
useRef is used to create a reference to a DOM element or store mutable values that
don’t trigger re-renders when updated.
DOM Access Example:
const inputRef = useRef(null);
function focusInput() {
inputRef.current.focus();
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. useMemo
useMemo memoizes a computed value, avoiding unnecessary recalculations on
every render. It’s useful when computations are expensive or depend on large data
sets.
Syntax:
const memoizedValue = useMemo(() => computeExpensiveValue(a, b), [a, b]);
Only recalculates when dependencies (a, b) change.
Helps prevent performance bottlenecks in complex apps.
Example:
const sortedItems = useMemo(() => {
return items.sort((a, b) => a.value - b.value);
}, [items]);
Without useMemo, sort() would run on every render even if items hasn’t changed.
4. useCallback
useCallback memoizes a function, ensuring it doesn't get recreated on every render
unless its dependencies change. It’s particularly useful when passing callbacks to
child components to prevent unnecessary renders.
Syntax:
const memoizedCallback = useCallback(() => {
doSomething(a, b);
}, [a, b]);
Prevents function recreation unless dependencies change.
Often used with React.memo to avoid re-rendering child components.
Example:
const handleClick = useCallback(() => {
console.log('Button clicked!');
}, []);
Without useCallback, handleClick would be a new function every time the
component re-renders, possibly causing child components to re-render
unnecessarily.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
1. Controlled Components
A controlled component is one where the form data is handled by the React
component's state. The input element’s value is set by React, and any user
interaction is managed through state updates.
Example:
function ControlledInput() {
const [value, setValue] = React.useState('');
return (
<input type="text" value={value} onChange={handleChange} />
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. Uncontrolled Components
An uncontrolled component manages its own state internally via the DOM, not React.
You access the value using a ref instead of storing it in component state.
Example:
function UncontrolledInput() {
const inputRef = React.useRef();
return (
<div>
<input type="text" ref={inputRef} />
<button onClick={handleSubmit}>Submit</button>
</div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Controlled components use React state to manage input values, while uncontrolled
components rely on the DOM. Controlled components give you more control and
consistency but with more code; uncontrolled components are simpler but less
powerful. Choose the approach that fits the complexity and needs of your form.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Lifting State Up
In React, “lifting state up” refers to the process of moving state from a child
component to a common parent component, so that multiple components can share
and access the same state. This concept is essential when two or more sibling
components need to communicate or stay in sync.
Why Lift State Up?
By default, each React component manages its own state. But sometimes, separate
components need access to the same data. For example, if a form input is in one
component and the result display is in another, both need to share the same data.
Instead of duplicating state, we lift it up to their closest common ancestor and pass it
down via props.
Real-World Example
Imagine two components: one input and one display. You want the display to update
as you type into the input.
Without lifting state:
Each component has its own state, and they can’t share it easily.
With lifted state:
You move the state to their common parent so both can read/write it.
Code Example
function Parent() {
const [text, setText] = React.useState('');
return (
<div>
<TextInput text={text} onTextChange={setText} />
<TextDisplay text={text} />
</div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function App() {
return (
<BrowserRouter>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</BrowserRouter>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
<BrowserRouter>: The router component that uses the browser’s URL to keep UI
in sync.
<Routes>: New in v6, this replaces Switch from v5 and matches the best possible
route.
<Route>: Maps a path to a component.
element: Instead of component, v6 uses the element prop, which receives a JSX
element.
4. Nested Routes
React Router v6 supports nested routing — helpful for layouts with sub-pages.
<Route path="/dashboard" element={<Dashboard />}>
<Route path="profile" element={<Profile />} />
<Route path="settings" element={<Settings />} />
</Route>
Navigating to /dashboard/profile will render Dashboard with Profile inside it.
Use <Outlet /> in the parent component (Dashboard) to render child routes.
5. Navigation
To programmatically or manually navigate between pages, use:
import { Link, useNavigate } from 'react-router-dom';
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
6. Route Parameters
React Router allows you to pass dynamic values in URLs using : syntax.
<Route path="/user/:id" element={<User />} />
Inside the User component, access the parameter:
import { useParams } from 'react-router-dom';
const { id } = useParams();
8. Redirects
To redirect in v6, use:
import { Navigate } from 'react-router-dom';
React Router v6+ brings a modern, more intuitive syntax for managing routing in
React apps. With features like nested routes, route parameters, programmatic
navigation, and a simplified API, it's easier than ever to build complex navigational
flows while keeping your UI consistent and responsive. Understanding React Router
is essential for building scalable, user-friendly React applications.
Custom Hooks –
Custom Hooks are a powerful feature in React that allow you to extract and reuse
component logic in a clean, reusable way. They’re simply JavaScript functions that
start with the word use and can call other hooks like useState, useEffect, useRef, and
more.
Why Use Custom Hooks?
React’s built-in hooks help manage state, side effects, refs, context, and more.
However, as components grow, their logic can become complex and repetitive.
Custom hooks let you encapsulate that logic into reusable functions.
This leads to:
Cleaner components: Logic is abstracted away.
Reusability: The same hook can be used across multiple components.
Better organization: Logic is grouped by behavior, not lifecycle or UI.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function useWindowWidth() {
const [width, setWidth] = useState(window.innerWidth);
useEffect(() => {
const handleResize = () => setWidth(window.innerWidth);
window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
}, []);
return width;
}
You can now use this hook in any component:
function ResponsiveComponent() {
const width = useWindowWidth();
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
useEffect(() => {
let isMounted = true;
fetch(url)
.then(res => res.json())
.then(json => {
if (isMounted) {
setData(json);
setLoading(false);
}
});
return () => {
isMounted = false;
};
}, [url]);
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
This hook abstracts API fetching and can be used like this:
const { data, loading } = useFetch('https://api.example.com/users');
Custom hooks are an elegant way to extract and reuse stateful logic in React. By
creating your own hooks, you keep components simple and focused, while making
your app’s logic modular, testable, and maintainable. They’re one of the most
powerful patterns in modern React development.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
return (
<ThemeContext.Provider value={{ theme, toggleTheme }}>
{children}
</ThemeContext.Provider>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function Header() {
const { theme, toggleTheme } = useContext(ThemeContext);
return (
<header style={{ backgroundColor: theme === 'dark' ? '#333' : '#eee' }}>
<button onClick={toggleTheme}>Toggle Theme</button>
</header>
);
}
function Root() {
return (
<ThemeProvider>
<App />
</ThemeProvider>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. Configure Store
import { configureStore } from '@reduxjs/toolkit';
import counterReducer from './counterSlice';
3. Use in Components
import { useSelector, useDispatch } from 'react-redux';
import { increment } from './counterSlice';
function Counter() {
const count = useSelector((state) => state.counter.value);
const dispatch = useDispatch();
return (
<div>
<p>{count}</p>
<button onClick={() => dispatch(increment())}>+1</button>
</div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
<label>Email</label>
<Field name="email" type="email" />
<ErrorMessage name="email" />
<button type="submit">Submit</button>
</Form>
)}
</Formik>
);
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
In this example:
Formik wraps the form and handles all state.
Field automatically binds inputs to Formik’s state.
ErrorMessage shows validation errors.
✅ What is Yup?
Yup is a JavaScript schema validation library often used with Formik. It allows you to
define rules for each field and perform validation easily.
Example schema using Yup:
import * as Yup from 'yup';
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function Users() {
const [users, setUsers] = useState([]);
useEffect(() => {
fetch('https://jsonplaceholder.typicode.com/users')
.then((res) => res.json())
.then((data) => setUsers(data))
.catch((error) => console.error('Error:', error));
}, []);
return (
<ul>
{users.map(user => <li key={user.id}>{user.name}</li>)}
</ul>
);
}
Pros of Fetch:
Native to browsers – no need to install anything.
Simple for basic use cases.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Cons:
No automatic JSON transformation on POST.
Doesn’t support request cancellation or timeout natively.
More verbose error handling.
📦 Axios
Axios is a promise-based HTTP client that works in both the browser and Node.js. It
provides a cleaner syntax, automatic JSON handling, and better error responses.
Installing Axios:
npm install axios
Example: Using Axios in React
import axios from 'axios';
import { useEffect, useState } from 'react';
function Users() {
const [users, setUsers] = useState([]);
useEffect(() => {
axios.get('https://jsonplaceholder.typicode.com/users')
.then((response) => setUsers(response.data))
.catch((error) => console.error('Error:', error));
}, []);
return (
<ul>
{users.map(user => <li key={user.id}>{user.name}</li>)}
</ul>
);
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Pros of Axios:
Automatically parses JSON.
Simpler syntax for POST, PUT, DELETE.
Better error handling (error.response, error.request).
Supports request cancellation, timeouts, and interceptors.
Cons:
Requires installation.
Slightly larger bundle size than using fetch.
✅ Choosing Between Fetch and Axios
Use Fetch if:
You want a zero-dependency solution.
Your HTTP needs are simple.
Use Axios if:
You need advanced features like interceptors, timeouts, or consistent error
handling.
You’re building a production-grade app and want cleaner, more robust code.
📌 Tips for API Integration
Handle loading and error states gracefully.
Use useEffect for fetching on component mount.
Consider using custom hooks (useFetch, useApi) to encapsulate API logic.
For larger apps, use libraries like React Query or SWR for caching, background
updates, and synchronization.
Environment Variables
Environment variables are key-value pairs used to configure applications without
hardcoding sensitive or environment-specific information directly into your code. In
React, environment variables are particularly helpful for storing API keys, base URLs,
feature flags, or any value that may differ between development, staging, and
production environments.
🧠 Why Use Environment Variables?
1. Security – Keep sensitive data like API keys or secrets out of your codebase.
2. Flexibility – Easily switch between development, test, and production settings.
3. Maintainability – Centralize configuration for cleaner, reusable code.
🌍 Setting Up Environment Variables in React
In React (especially apps created with Create React App or Vite), environment
variables must follow certain naming conventions to be used securely and correctly.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
// .env.production
REACT_APP_API_URL=https://api.mysite.com
Then in your React code:
axios.get(`${process.env.REACT_APP_API_URL}/posts`);
When you run npm run build, the correct .env.production values are injected.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
🧼 Best Practices
Never commit sensitive info (like secret keys) in .env files.
Use .env.local for machine-specific or private values.
Always prefix with REACT_APP_ or VITE_ so the build tool includes them.
Use .gitignore to exclude sensitive .env.local files from version control.
🏁 Conclusion
Environment variables are essential for building flexible, scalable, and secure React
apps. Whether you’re switching between development and production APIs or
enabling feature flags, using .env files keeps your code cleaner and your
configuration more manageable. Just remember: in frontend apps, all environment
variables are public at build time — so use them wisely!
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
However, there are also some trade-offs. Using a large UI library can increase the size
of the application if not optimized properly, potentially affecting performance.
Additionally, developers may need to learn the specific conventions or syntax of a
library, which can increase the initial learning curve.
In conclusion, styling and UI libraries are essential tools in front-end development,
helping teams build polished interfaces efficiently. By leveraging these libraries
wisely—choosing the right one based on project needs and customizing as necessary
—developers can maintain high design quality while reducing time and effort.
function Header() {
return <h1 className={styles.title}>Hello</h1>;
}
Pros:
Familiar CSS syntax
Local scope eliminates conflicts
No inline styles – works well with tools like media queries and pseudo-classes
Cons:
Still requires manual class name management
Doesn’t support dynamic styling out of the box
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. Styled Components
Styled Components is a library for writing CSS-in-JS, primarily used in React
applications. It lets you write actual CSS code inside JavaScript, attaching styles
directly to components. This approach combines component logic and styling into a
single file.
Example:
import styled from 'styled-components';
function App() {
return <Button>Click Me</Button>;
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Styled Components are dynamic, meaning you can pass props and adjust styling
conditionally.
Pros:
Styles are tightly coupled with components
Dynamic styling using props
No class name conflicts
Built-in support for theming
Cons:
Larger bundle size if not optimized
Debugging can be harder compared to plain CSS
Performance overhead in some cases
3. Tailwind CSS
Tailwind CSS is a utility-first CSS framework. Instead of writing custom CSS, you
apply predefined utility classes directly in the HTML or JSX. Each class represents a
single styling rule, like margin, padding, or color.
Example:
function Card() {
return (
<div className="bg-white p-4 rounded-lg shadow-md">
<h2 className="text-xl font-bold text-gray-800">Title</h2>
<p className="text-gray-600">Description goes here.</p>
</div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function App() {
return <Button variant="contained">Click Me</Button>;
}
Pros:
Professional, polished design
Great documentation and examples
Easy to integrate with custom themes
Consistent UI across large applications
Cons:
Opinionated design (Material Design may not suit all projects)
More complex customization compared to lighter libraries
Larger bundle size if not optimized
Best For: Teams looking for a production-ready, enterprise-grade UI with rich
functionality and consistent design.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. ShadCN
ShadCN/UI is a modern, unstyled component library built using Radix UI primitives
and Tailwind CSS. Rather than giving you fully styled components, ShadCN gives you
logic-rich components that you style yourself using Tailwind or your preferred
utility-first approach.
Key Features:
Built on top of Radix (for accessibility and logic)
Tailwind CSS compatible
Highly customizable – you control the styling
Encourages copy-and-paste and tweaking approach
Example:
import { Button } from "@/components/ui/button";
function App() {
return <Button className="bg-black text-white">Click Me</Button>;
}
Pros:
Complete design freedom
Utility-class styling with Tailwind
Clean, modern architecture
Perfect for design systems and custom UIs
Cons:
Requires Tailwind knowledge
Minimal out-of-the-box styling
Still maturing as a project
Best For: Developers who want full control over styles while using accessible,
headless components and a modern tech stack.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
3. Chakra UI
Chakra UI is a component library and design system for React that prioritizes
accessibility, flexibility, and ease of use. It uses a style-prop system, which lets you
apply styling directly via component props—no external CSS or Tailwind required.
Key Features:
Accessible out of the box
Dark mode support
Built-in responsive design with style props
Easy theming and customization
Example:
import { Button } from "@chakra-ui/react";
function App() {
return <Button colorScheme="teal">Click Me</Button>;
}
Pros:
Great developer experience
Fast prototyping with style props
Accessible and responsive
Lightweight and customizable
Cons:
Less control over deeply customized designs
Can lead to verbose JSX with many style props
Slightly opinionated styling
Best For: Teams and individuals who want an intuitive, styled component system
with strong accessibility and design defaults.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Responsive design
Responsive design is a web development approach aimed at creating websites and
applications that adapt seamlessly to different screen sizes, orientations, and
devices—whether it’s a smartphone, tablet, laptop, or desktop monitor. The core idea
is to ensure that users have a consistent and optimized experience regardless of how
they access your content.
Why Responsive Design Matters
With the vast variety of devices in use today, fixed-width layouts that work only on
desktops are no longer practical. More people browse the web on mobile devices
than ever before, so having a site that doesn’t adjust to smaller screens leads to poor
usability, high bounce rates, and missed engagement opportunities.
Responsive design helps solve this by ensuring:
Text is readable without zooming
Images scale appropriately
Layouts adjust and rearrange based on screen width
Navigation remains usable across all devices
Core Techniques of Responsive Design
Fluid Grids
Instead of using fixed pixels, responsive layouts use relative units like percentages
(%) or viewport width (vw). This allows containers and elements to resize
proportionally based on screen size.
Flexible Images
Images and media should scale with their containers. CSS rules like max-width: 100%
ensure images don’t overflow their containers, making them flexible within different
layouts.
Media Queries
Media queries are a key feature in CSS that let you apply styles based on the
characteristics of the device or viewport.
Example:
@media (max-width: 768px) {
.menu {
flex-direction: column;
}
}
This adjusts the .menu layout only when the screen width is 768 pixels or less.
Responsive Typography
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Using scalable units like em, rem, or even newer units like clamp() helps text adjust
appropriately for different screen sizes without looking too large or too small.
Tools and Frameworks
Many modern CSS frameworks make responsive design easier:
Tailwind CSS: Utility-first classes like md:flex or lg:hidden allow for responsive
design directly in HTML.
Bootstrap: Provides a grid system and responsive classes out of the box.
Chakra UI: Uses responsive arrays and style props to handle breakpoints in JSX.
Benefits of Responsive Design
Improved User Experience: Easy navigation, readable text, and flexible layouts
across all devices
Better SEO: Google prioritizes mobile-friendly websites in search rankings
Cost-Effective: One responsive site works across devices, eliminating the need for
separate mobile versions
Easier Maintenance: Changes only need to be made in one codebase
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
function Box() {
return (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.5 }}
>
Hello!
</motion.div>
);
}
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Pros:
Intuitive and beginner-friendly
Great for UI/UX-focused projects
Advanced features like layout animations and gestures
Strong community and documentation
Cons:
More focused on UI animations than physics
Slightly larger bundle size compared to lighter libraries
Best For: Developers looking for smooth, design-oriented animations with minimal
setup.
2. React Spring
React Spring is a spring-physics-based animation library that focuses on creating
natural-looking, fluid interactions. Rather than timeline-based animations (like
Framer Motion), React Spring models motion with physics, mimicking real-world
behaviors like tension, friction, and mass.
Key Features:
Physics-based animation engine
Supports imperative and declarative syntax
Great for choreographed and sequence-based animations
Works across web and React Native
.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Example:
import { useSpring, animated } from 'react-spring';
function Box() {
const styles = useSpring({ opacity: 1, from: { opacity: 0 } });
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Deployment
Deployment is the process of releasing your application to a live environment where
users can access it. This typically involves:
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Building the application: Tools like Vite, Webpack, or Next.js bundle your code for
production.
Hosting: Deploying your app to a platform like Vercel, Netlify, Render, or AWS.
Continuous Deployment (CD): Automates the deployment process after each
push to the main branch, ensuring updates go live quickly and reliably.
Monitoring & Rollbacks: Tools like Sentry or LogRocket help monitor issues post-
deployment, and platforms often offer rollback options if something goes wrong.
Together, testing and deployment ensure a stable, scalable, and user-friendly
application. Proper testing minimizes bugs, while smooth deployment gets features
into users’ hands quickly and safely.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Jest is great for unit testing pure functions, like utilities or logic-heavy components.
It can also be used with other libraries to test UI components.
Pros:
All-in-one solution: runner, assertions, and mocking
Fast and easy to configure
Great community support
Works well with TypeScript and Babel
Cons:
Limited by itself for testing complex UI interactions
2. React Testing Library (RTL)
React Testing Library is a lightweight solution for testing React components. Unlike
older tools like Enzyme (which focused on internal component structures), RTL
encourages testing from the user’s perspective—interacting with rendered output
instead of internal implementation details.
Key Features:
Querying DOM elements like users do (e.g., by text, role, placeholder)
Simulating user events (clicks, input, etc.)
Encourages accessibility by using roles and labels
Integrates easily with Jest
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Basic Example:
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Button from './Button';
expect(onClick).toHaveBeenCalledTimes(1);
});
Pros:
Tests reflect real user behavior
Encourages accessibility-first development
Simple, readable syntax
Works seamlessly with Jest
Cons:
Doesn't test internal component logic (which is by design)
May be too abstract for deeply technical logic testing
Best Practices with Jest + RTL
Test what users care about: Focus on rendered output and behavior, not
implementation details.
Keep tests isolated: Each test should be independent and not rely on others.
Use descriptive test names: Clear names make it easier to understand test intent.
Mock only when necessary: Over-mocking can make tests brittle and less
meaningful.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Performance optimization
Performance optimization in web development refers to improving the speed,
responsiveness, and efficiency of a website or application. A well-optimized app not
only loads faster but also feels smoother during interactions, resulting in a better
user experience, improved SEO rankings, and lower bounce rates.
In modern React and JavaScript development, there are several techniques and best
practices used to optimize performance at different levels—from code and rendering
to network and infrastructure.
1. Code Splitting
Code splitting helps reduce the size of the JavaScript bundle by loading only the
necessary code for a specific page or component. This leads to faster initial load
times.
In React, this is typically done using React.lazy() and Suspense:
const LazyComponent = React.lazy(() => import('./Component'));
<Suspense fallback={<div>Loading...</div>}>
<LazyComponent />
</Suspense>
This defers loading the component until it’s needed, improving initial performance.
2. Lazy Loading Assets
Images, videos, and heavy components should be lazy loaded—loaded only when
they enter the viewport. This reduces the load on the browser and saves bandwidth.
Tools like the loading="lazy" attribute on <img> tags or libraries like react-lazyload
can help implement this.
3. Memoization & Avoiding Unnecessary Renders
React components re-render when props or state change. If not managed carefully,
this can slow down your app. Memoization helps avoid re-rendering when
unnecessary:
React.memo() for functional components
useMemo() to memoize calculations
useCallback() to memoize functions passed as props
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
4. Optimizing Images
Images are often the largest assets on a web page. To optimize them:
Use modern formats like WebP or AVIF
Compress images without significant quality loss
Use responsive sizes (srcset) to load the right size per device
Use tools like ImageKit, Cloudinary, or Next.js Image component for automatic
optimization
5. Efficient State Management
Overusing global state or improper state updates can trigger excessive renders. Tools
like Zustand, Jotai, or context carefully scoped to only needed components can help
reduce unnecessary updates.
Also, consider colocating state—keeping state as close as possible to where it's used
to avoid prop drilling and global re-renders.
6. Minification and Compression
Before deployment, always minify JavaScript, CSS, and HTML to reduce file size.
Tools like Terser, esbuild, or build tools like Vite and Webpack do this automatically.
Gzip or Brotli compression on the server side further reduces transfer size over the
network.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
2. Netlify
Netlify is another popular platform that supports static sites and modern front-end
frameworks like React, Vue, Angular, and more. It’s known for its simplicity and
robust features tailored to front-end development.
Key Features:
Continuous deployment from Git repositories
Custom domains, HTTPS, and form handling
Redirects, rewrites, and functions (Netlify Functions for serverless backends)
Deploy previews for pull requests
Plugin ecosystem for extended functionality
How it works: Netlify watches your connected Git repo, builds your app when you
push changes, and deploys it to its CDN. You can also drag-and-drop a build folder
manually to deploy instantly.
Best For: Static sites, JAMstack applications, and React/Vite projects needing
serverless capabilities and quick CI/CD setup.
3. GitHub Pages
GitHub Pages is a free hosting service from GitHub that lets you deploy static
websites directly from your GitHub repository.
Key Features:
Simple and free hosting for static content
Direct integration with GitHub repositories
Works well with static site generators (like Jekyll, Hugo)
Custom domains with HTTPS support
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
How it works: You push your HTML/CSS/JS (or the build output of your React app) to
a specific branch (usually gh-pages), and GitHub serves that content. For React
projects, tools like gh-pages NPM package can automate this.
Each of these platforms offers powerful features for modern front-end deployment,
with varying levels of customization and complexity.
Vercel is ideal for dynamic and framework-heavy apps like Next.js.
Netlify offers flexibility, serverless functions, and is perfect for JAMstack apps.
GitHub Pages is a no-frills, easy option for hosting static sites for free.
Choosing the right platform depends on your project needs, build process, and
desired developer experience.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Hiring Prep
Once you've built a solid portfolio, it's time to prepare for the job search and
interviews. Hiring prep is a critical step in landing a job as a developer, and it involves
several key areas:
Resume Building:
Highlight your technical skills, projects, and any relevant experience.
Tailor your resume to each job, focusing on the skills and experiences that are
most relevant.
Keep it concise and clear, showcasing the impact you made in your projects or
past jobs.
Interview Practice:
Technical Interviews: Practice coding problems on platforms like LeetCode,
HackerRank, or CodeSignal. Focus on data structures, algorithms, and problem-
solving.
System Design: Be ready to discuss architecture, scalability, and how you would
design complex systems.
Behavioral Interviews: Prepare to talk about your experiences, challenges,
teamwork, and problem-solving.
Mock Interviews:
Practice mock interviews with peers or use platforms like Pramp or
Interviewing.io for live simulations.
Networking:
Attend meetups, conferences, or use LinkedIn to connect with professionals in
your field.
Engage with tech communities online, contribute to open-source projects, or
collaborate with other developers.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
E-commerce app
An e-commerce app is a platform designed for online buying and selling of goods and
services. It allows businesses to display products, accept orders, process payments,
and manage inventory, all in a digital environment. E-commerce apps are typically
mobile or web applications that enable a seamless shopping experience for users,
from browsing products to completing transactions.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Push Notifications:
Users can receive notifications about order updates, promotions, and discounts,
which encourages repeat purchases and keeps users engaged.
Tech Stack for Building an E-Commerce App
To build an e-commerce app in 2025, you might use the following technologies:
Front-End: React, Angular, or Vue.js for web apps; Swift (iOS) and Kotlin (Android)
for mobile apps.
Back-End: Node.js with Express, or Django for handling server-side logic,
database management, and API endpoints.
Database: MongoDB or PostgreSQL for product and order data storage.
Payment Gateway: Stripe or PayPal for processing transactions.
Dashboard/Admin Panel
A Dashboard/Admin Panel is a critical feature of many web and mobile applications,
providing a centralized interface for administrators, managers, and business owners
to manage, monitor, and control various aspects of their platform. It serves as a
control center for handling data, tracking performance, and executing administrative
tasks. These panels are commonly used in applications like e-commerce sites,
content management systems (CMS), social media platforms, and SaaS tools.
Key Features of a Dashboard/Admin Panel
User Authentication and Authorization:
Admin panels require secure user authentication to ensure that only authorized
personnel can access the administrative interface. This often involves login
systems with multi-factor authentication (MFA) to enhance security.
Role-based Access Control (RBAC) is essential to control which sections or
actions users can access based on their role (e.g., admin, manager, content
creator).
Data Visualization:
One of the main functions of a dashboard is to provide insights through data
visualization. Graphs, charts, and tables are used to display data like sales
performance, website traffic, or user activity. This allows admins to monitor key
metrics at a glance and make informed decisions.
Popular tools for data visualization include Chart.js, D3.js, or Google Charts.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Content Management:
Admin panels often feature tools to manage content, such as adding, updating, or
deleting product listings, blog posts, or user-generated content. These panels
typically provide intuitive user interfaces to simplify content creation and
management without requiring technical skills.
In an e-commerce platform, an admin panel might allow the management of
product catalogs, inventory tracking, pricing, and shipping information.
User Management:
An admin panel provides functionalities to manage users on the platform. Admins
can view user profiles, assign roles, ban or delete accounts, and resolve issues.
For example, in an e-commerce app, an admin might monitor customer orders,
process returns, and resolve complaints.
Order and Transaction Management:
For platforms like e-commerce apps, a key function of the admin panel is
managing orders. Admins can track new orders, update shipping statuses, issue
refunds, and view transaction history.
Integration with payment gateways (like Stripe or PayPal) enables real-time
tracking of payment statuses.
Analytics and Reporting:
Admin panels often include a reporting section, where users can generate
detailed reports on various activities, such as sales, user behavior, and traffic.
This data can help businesses understand trends and optimize operations.
Settings and Configuration:
Admin panels provide configuration options to adjust platform settings, including
payment configurations, shipping methods, tax rates, and user interface
customization.
This allows administrators to easily update and modify the system without
requiring developers.
Notifications and Alerts:
To keep admins informed, many dashboards include real-time notifications and
alerts for important events like low stock, pending orders, or system errors. This
ensures that admins can quickly address issues.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Blog or CMS
A Blog or Content Management System (CMS) is a software platform that enables
users to create, manage, and publish content on the web without needing extensive
technical knowledge. These systems are commonly used for running blogs, news
websites, e-commerce platforms, and corporate websites, providing a user-friendly
interface for non-technical users to manage content.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
Multimedia Management:
Blogs and CMS platforms allow users to manage and embed multimedia, such as
images, videos, and audio files. These platforms often include a media library
where users can upload and organize media files, making it easy to add visuals to
blog posts or pages.
Themes and Customization:
A CMS provides customizable themes and templates, allowing users to adjust the
appearance of their blog or website. Users can choose from a wide range of pre-
designed themes or create custom layouts using simple drag-and-drop tools.
Some platforms also allow for more advanced customizations using HTML, CSS,
or JavaScript for users with coding knowledge.
User Roles and Permissions:
In a CMS, there is typically a role-based access control system. Different user
roles, such as admin, editor, and author, define the level of access a user has. For
instance, an admin can create, edit, and publish content, while authors may only
be able to write and submit posts for review.
Plugins and Extensions:
Many CMS platforms allow users to extend functionality through plugins and
extensions. These can add new features like social media integration, comment
sections, e-commerce capabilities, and analytics tracking.
Analytics and Reporting:
A CMS often integrates with analytics tools (like Google Analytics) to track visitor
activity on the site. Admins can view reports on traffic, popular content, user
behavior, and other metrics to improve site performance.
Tech Stack for Building a Blog/CMS
For a modern blog or CMS, developers often use technologies such as:
Front-End: React, Vue.js, or traditional HTML/CSS for building the user interface.
Back-End: Node.js, Django, or Ruby on Rails for handling server-side logic.
Database: MongoDB, MySQL, or PostgreSQL for storing content, user data, and
media files.
Authentication: JWT (JSON Web Tokens) or OAuth for secure user authentication.
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
WWW.CODTECHITSOLUTIONS.COM
CODTECH IT SOLUTIONS PVT.LTD
Information Technology Services
LinkedIn Optimization
Your LinkedIn profile acts as an online professional presence, allowing you to
network, build connections, and showcase your career. Optimizing your LinkedIn
profile ensures it stands out to potential employers, recruiters, and collaborators.
Profile Picture and Headline:
Use a professional, high-quality profile picture. Your headline should go beyond your
job title and describe your unique value proposition (e.g., “Full Stack Developer |
Specializing in React & Node.js | Passionate About Building Scalable Apps”).
Compelling Summary:
The Summary section is your chance to tell your story. Write a clear and concise
summary that highlights your professional journey, skills, and achievements. Use it
as an elevator pitch to grab attention.
Skills and Endorsements:
List relevant skills on your profile and ask colleagues or peers to endorse them.
Having endorsed skills boosts your credibility and visibility in LinkedIn searches.
Recommendations:
Request recommendations from colleagues, managers, or clients. These act as
testimonials to your expertise and work ethic and are highly valuable to potential
employers.
Engagement:
Regularly post content, share industry news, and engage with others' posts. This
helps increase your visibility, build credibility, and grow your professional network.
Customized URL:
Create a custom LinkedIn URL that’s short, professional, and easy to share. A
personalized URL (e.g., linkedin.com/in/yourname) makes it easier for people to find
you.
Conclusion
Optimizing both your resume and LinkedIn profile is an ongoing process that involves
tailoring your content to reflect your skills and achievements while ensuring both are
visible and accessible to the right audience. A well-crafted resume increases your
chances of landing interviews, while an optimized LinkedIn profile expands your
professional network and enhances your online presence. By regularly updating and
fine-tuning these tools, you position yourself for success in today’s job market.
WWW.CODTECHITSOLUTIONS.COM