0% found this document useful (0 votes)
6 views4 pages

React PDF 1

The document is a collection of React interview questions and answers, covering essential topics such as JSX, components, state vs. props, hooks, the Virtual DOM, and performance optimization techniques. It provides insights into advanced concepts like error boundaries, portals, server-side rendering, and custom hooks. This resource is aimed at helping candidates prepare for React-related job interviews in 2025.

Uploaded by

aruladictor
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)
6 views4 pages

React PDF 1

The document is a collection of React interview questions and answers, covering essential topics such as JSX, components, state vs. props, hooks, the Virtual DOM, and performance optimization techniques. It provides insights into advanced concepts like error boundaries, portals, server-side rendering, and custom hooks. This resource is aimed at helping candidates prepare for React-related job interviews in 2025.

Uploaded by

aruladictor
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/ 4

React Interview Questions and Answers (2025)

By Ankit Sharma

linkedin.com/in/ankit7rma/

Question 1: What is JSX?

JSX is a syntax extension for JavaScript that allows you to write HTML-like code within
JavaScript. It gets transformed into regular JavaScript objects and function calls during
compilation. JSX makes React code more readable and writing templates more intuitive.

Question 2: What are React Components?

Components are reusable, self-contained pieces of UI that can accept inputs (props) and
return React elements. They can be either function components (modern approach) or
class components (traditional approach). Components help in building modular,
maintainable applications.

Question 3: What's the difference between state and props?

Props are read-only inputs passed to components from their parents, while state is internal,
mutable data managed by the component itself. Props flow down, state is contained. Use
props for component configuration, state for interactive data that changes over time.

Question 4: Explain React Hooks

Hooks are functions that allow you to use state and other React features in function
components. Common hooks include useState (state management), useEffect (side
effects), useContext (context consumption), and useRef (mutable references). They must
be called at the top level of components.
Question 5: What is the Virtual DOM?

The Virtual DOM is a lightweight copy of the actual DOM in memory. React uses it to
optimize rendering by first making changes to this virtual representation, then efficiently
updating only the necessary parts of the real DOM through a process called reconciliation.

Question 6: Explain useEffect's dependency array

The dependency array in useEffect determines when the effect should run. Empty array ([])
means run once on mount, no array means run on every render, and array with
dependencies means run when those values change. It's crucial for optimizing
performance and preventing infinite loops.

Question 7: What are React Keys and why are they important?

Keys are special attributes used to help React identify which items have changed, been
added, or been removed in lists. They should be stable, unique identifiers. Keys improve
performance by allowing React to update only the necessary items instead of re-rendering
the entire list.

Question 8: What is React Context?

Context provides a way to pass data through the component tree without having to pass
props manually at every level. It's useful for sharing global data like themes, user
authentication, or language preferences. However, it shouldn't be used for every state
management need.

Question 9: What is Code Splitting in React?

Code splitting is a technique to split your code into small chunks and load them on
demand. React.lazy() and Suspense enable component-level code splitting. This improves
initial load time by only loading the necessary code for the current view.
Question 10: Explain React's Error Boundaries

Error Boundaries are components that catch JavaScript errors in their child component
tree, log errors, and display fallback UI. They prevent the entire app from crashing due to
errors in one component. They must be class components using specific lifecycle methods.

Question 11: What are React Portals?

Portals provide a way to render children into a DOM node that exists outside the DOM
hierarchy of the parent component. Common uses include modals, tooltips, and floating
menus. They maintain event bubbling through the React tree regardless of actual DOM
position.

Question 12: What is Server-Side Rendering (SSR)?

SSR is rendering React components on the server rather than in the browser. Benefits
include better SEO, faster initial page load, and improved performance on low-powered
devices. Next.js is a popular framework for implementing SSR in React applications.

Question 13: Explain React's Strict Mode

StrictMode is a development mode feature that highlights potential problems in an


application. It enables additional checks and warnings for deprecated features, unsafe
lifecycles, legacy API usage, and helps ensure better coding practices.

Question 14: What are Custom Hooks?

Custom Hooks are JavaScript functions that start with 'use' and may call other hooks. They
allow you to extract component logic into reusable functions, share stateful logic between
components, and keep components clean and DRY (Don't Repeat Yourself).
Question 15: How do you optimize React performance?

Key optimization techniques include: using React.memo for component memoization,


useMemo for expensive calculations, useCallback for stable function references, proper
key usage in lists, code splitting with React.lazy, and implementing virtualization for long
lists.

You might also like