React_Fresher_Interview_Questions
React_Fresher_Interview_Questions
---
Basic Questions
1. What is React?
React is a JavaScript library used for building user interfaces. It allows developers to create reusable UI co
---
- Virtual DOM: Optimizes rendering by updating only the necessary parts of the DOM.
- JSX: A syntax extension that allows writing HTML-like code within JavaScript.
---
3. What is JSX?
JSX stands for JavaScript XML. It is a syntax extension for JavaScript that allows you to write HTML eleme
---
4. What are components in React?
Components are the building blocks of a React application. They are of two types:
---
The Virtual DOM is a lightweight copy of the real DOM. React uses it to compare changes (diffing) and upd
---
- Props: Data passed from a parent component to a child component and are read-only.
---
The key helps React identify which items in a list have changed, been added, or removed. It improves the r
---
Intermediate Questions
- Controlled Components: Form elements whose values are controlled by React state.
- Uncontrolled Components: Form elements that maintain their state internally.
---
React uses synthetic events, which are a wrapper around the native events to ensure cross-browser compa
---
Hooks allow you to use state and other React features in functional components. Common hooks include u
---
useEffect is used to handle side effects in functional components, such as fetching data, subscribing to eve
---
---
Example:
---
The Context API provides a way to share data (like theme or user info) across components without passing
---
Fragments let you group multiple elements without adding an extra node to the DOM.
<>
<h1>Hello</h1>
<p>World!</p>
</>
---
- Lazy Loading: Loads components only when they're needed using React.lazy and Suspense.
---
17. How do you optimize a React application?
---
Reconciliation is the process of updating the DOM by comparing the new Virtual DOM with the previous on
---
---
Redux is a state management library often used with React to manage global state. It uses a single store, a
---
Practical Questions
21. How would you handle form validation in React?
Use controlled components with validation logic in the event handlers. Alternatively, use libraries like Formi
---
---
- Unmounting: componentWillUnmount().
---
---