[go: up one dir, main page]

0% found this document useful (0 votes)
42 views6 pages

React_Fresher_Interview_Questions

Uploaded by

mca.lj.a.21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views6 pages

React_Fresher_Interview_Questions

Uploaded by

mca.lj.a.21
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

React.

js Fresher Interview Questions and Answers

---

Basic Questions

1. What is React?

React is a JavaScript library used for building user interfaces. It allows developers to create reusable UI co

---

2. What are the main features of React?

- 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.

- Components: Enables modular and reusable code.

- One-Way Data Binding: Ensures unidirectional data flow.

- React Hooks: Manage state and lifecycle in functional components.

---

3. What is JSX?

JSX stands for JavaScript XML. It is a syntax extension for JavaScript that allows you to write HTML eleme

const element = <h1>Hello, World!</h1>;

---
4. What are components in React?

Components are the building blocks of a React application. They are of two types:

- Functional Components: Functions that return JSX.

- Class Components: ES6 classes that extend React.Component.

---

5. What is the Virtual DOM, and how does it work?

The Virtual DOM is a lightweight copy of the real DOM. React uses it to compare changes (diffing) and upd

---

6. What is the difference between state and props in React?

- State: Local data that a component manages and can change.

- Props: Data passed from a parent component to a child component and are read-only.

---

7. What is the role of key in React?

The key helps React identify which items in a list have changed, been added, or removed. It improves the r

---

Intermediate Questions

8. What is the difference between controlled and uncontrolled components?

- Controlled Components: Form elements whose values are controlled by React state.
- Uncontrolled Components: Form elements that maintain their state internally.

---

9. How does React handle events differently than HTML?

React uses synthetic events, which are a wrapper around the native events to ensure cross-browser compa

---

10. What are React Hooks?

Hooks allow you to use state and other React features in functional components. Common hooks include u

---

11. What is the purpose of useEffect?

useEffect is used to handle side effects in functional components, such as fetching data, subscribing to eve

---

12. How do you pass data between components?

- Parent to Child: Using props.

- Child to Parent: Using callback functions.

- Global State: Using Context API or libraries like Redux.

---

13. What are higher-order components (HOC)?


HOCs are functions that take a component as an argument and return a new component. They're used to r

Example:

const EnhancedComponent = withHOC(OriginalComponent);

---

14. What is the Context API?

The Context API provides a way to share data (like theme or user info) across components without passing

---

Advanced Questions for Freshers

15. What are React Fragments?

Fragments let you group multiple elements without adding an extra node to the DOM.

<>

<h1>Hello</h1>

<p>World!</p>

</>

---

16. What are lazy loading and code splitting in React?

- Lazy Loading: Loads components only when they're needed using React.lazy and Suspense.

- Code Splitting: Divides code into smaller bundles to improve performance.

---
17. How do you optimize a React application?

- Use React.memo to prevent unnecessary renders.

- Split code with React.lazy.

- Use keys efficiently in lists.

- Optimize state management.

---

18. What is reconciliation in React?

Reconciliation is the process of updating the DOM by comparing the new Virtual DOM with the previous on

---

19. What is the difference between React.memo and useMemo?

- React.memo: Prevents unnecessary re-renders of a component.

- useMemo: Memoizes the result of a function to avoid recomputation.

---

20. What is Redux, and how does it relate to React?

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

---

22. How would you implement conditional rendering in React?

Use JavaScript operators like if, &&, or ternary operators.

{isLoggedIn ? <Dashboard /> : <Login />}

---

23. Can you describe a simple React lifecycle?

- Mounting: constructor(), componentDidMount().

- Updating: shouldComponentUpdate(), componentDidUpdate().

- Unmounting: componentWillUnmount().

---

24. How do you debug a React application?

- Use React Developer Tools.

- Add console logs.

- Use error boundaries to catch errors in components.

---

You might also like