React Interview Que
React Interview Que
1. What is React?
React is a JavaScript library for building user interfaces, developed by Facebook. It is
component-based and allows developers to build reusable UI components.
2. Explain JSX.
JSX (JavaScript XML) is a syntax extension for JavaScript that looks similar to HTML. It is used
with React to describe the UI structure. Browsers can't read JSX directly; it is transpiled to
regular JavaScript using tools like Babel.
o Props: Passed from a parent component and are immutable within the child.
o Unmounting: componentWillUnmount
o Uncontrolled: Form elements manage their own state via the DOM.
jsx
Copy code
jsx
Copy code
React Hooks
jsx
Copy code
React Router
Copy code
jsx
Copy code
Performance Optimization
o Optimize images.
29. How can you use the useMemo and useCallback hooks for performance optimization?
Use them to memoize values and functions to prevent unnecessary recalculations or re-
creations.
Advanced Topics
30. What is the difference between class components and functional components?
Class components use lifecycle methods and this. Functional components are simpler and
use hooks.
33. What is the difference between shallow comparison and deep comparison?