Basics
- What is React?
- React is a JavaScript library for building user interfaces, developed by Facebook. It uses a component-based architecture and virtual DOM for efficient updates.
- What are the main features of React?
- Component-based
- Virtual DOM
- Unidirectional data flow
- JSX (JavaScript XML)
- Declarative UI
- What is JSX?
- JSX is a syntax extension that looks like HTML but compiles to JavaScript (React.createElement).
- What are components in React?
- Independent, reusable pieces of UI. Types: Functional & Class components.
- Difference between Functional and Class components?
- Functional: Simpler, stateless (but with Hooks can manage state).
- Class: Use lifecycle methods, this.state.
- What is Virtual DOM?
- A lightweight copy of the real DOM. React updates the virtual DOM, calculates the diff, and applies changes to the real DOM efficiently.
- What is ReactDOM?
- A package that provides DOM-specific methods like ReactDOM.render().
- What are props in React?
- Props (properties) are read-only inputs to components.
- What is state in React?
- An object that determines how a component renders & behaves. Unlike props, it is mutable.
- Difference between state and props?
- Props: Immutable, passed from parent.
- State: Mutable, owned by component.
- What is a pure component?
- A component that renders the same output for the same props & state.
- What is React.Fragment?
- Allows grouping of elements without adding extra nodes to the DOM.
- What are keys in React?
- Unique identifiers for list elements, helping React track items efficiently.
- Why should keys be unique?
- To prevent rendering bugs and improve performance during reconciliation.
- What is reconciliation in React?
- The process by which React updates the DOM based on virtual DOM differences.
- What is create-react-app?
- A CLI tool that sets up a new React project with zero config.
- What is the difference between real DOM and virtual DOM?
- Real DOM: Slow updates, re-renders full tree.
- Virtual DOM: Faster, updates only changed nodes.
- What is conditional rendering?
- Rendering UI based on conditions using if, ternary operator, or logical &&.
- What is the difference between React and Angular?
- React: Library, unidirectional, JSX.
- Angular: Framework, two-way binding, TypeScript first.
- What is a controlled component?
- A form input element controlled by React via state.
React Hooks
- What are React Hooks?
- Functions that let you use state and lifecycle features in functional components.
- Name some common React Hooks.
- useState
- useEffect
- useContext
- useRef
- useReducer
- useMemo
- useCallback
- What is useState?
- A hook that adds state to functional components.
- What is useEffect?
- A hook for performing side effects (API calls, subscriptions, DOM updates).
- What is the difference between useEffect and componentDidMount?
- useEffect runs after every render (unless dependencies are provided).
- componentDidMount runs once after initial render (class components).
- What is useContext?
- Hook to consume context values without Consumer.
- What is useRef?
- A hook that returns a mutable object for persisting values across renders (like DOM references).
- What is useReducer?
- Hook for complex state management using reducer functions.
- What is useMemo?
- Memoizes a computed value to avoid unnecessary recalculations.
- What is useCallback?
- Memoizes a function to prevent unnecessary re-creations.
- What is custom hook?
- A reusable function starting with use that encapsulates hook logic.
- When should you use useMemo vs useCallback?
- useMemo: Memoize values.
- useCallback: Memoize functions.
- What is dependency array in useEffect?
- Determines when the effect runs. Empty array = only once.
- What happens if you don’t provide dependency array?
- The effect runs after every render.
- What happens if dependency array is empty?
- The effect runs only once (like componentDidMount).
- Can you use Hooks inside loops or conditions?
- No, hooks must run in the same order on every render.
- What are rules of hooks?
- Call hooks only at the top level.
- Call hooks only in React functions.
- Difference between useEffect and useLayoutEffect?
- useEffect: Runs asynchronously after paint.
- useLayoutEffect: Runs synchronously before paint.
- What is useImperativeHandle?
- Customizes the instance value exposed when using ref.
- Can you use multiple useEffect hooks in one component?
- Yes, effects can be split logically into multiple hooks.
Advanced Concepts
- What is higher-order component (HOC)?
- A function that takes a component and returns a new component with additional props/logic.
- What is render props pattern?
- A technique where a function is passed as a prop to control rendering.
- What is React Context API?
- Provides a way to share state globally without prop drilling.
- What are controlled vs uncontrolled components?
- Controlled: Value controlled by React state.
- Uncontrolled: Managed by DOM (via refs).
- What is React Router?
- A library for client-side routing in React apps.
- Difference between BrowserRouter and HashRouter?
- BrowserRouter: Uses HTML5 history API.
- HashRouter: Uses URL hash (#).
- What is lazy loading in React?
- Loading components only when needed using React.lazy and Suspense.
- What is code splitting in React?
- Splitting app into bundles to load only required code.
- What is Redux?
- A state management library with a single store and unidirectional data flow.
- What are Redux principles?
- Single source of truth
- State is read-only
- Changes via pure functions (reducers)
- What is difference between Redux and Context API?
- Redux: Better for complex apps with middleware, debugging, devtools.
- Context: Simpler, but not great for large state management.
- What are reducers in Redux?
- Pure functions that take state + action → return new state.
- What is middleware in Redux?
- Functions that intercept actions before reaching reducers (e.g., Redux Thunk, Saga).
- What is Redux Thunk?
- Middleware for async actions.
- What is Redux Saga?
- Middleware for handling async actions with generators.
- What is React Fiber?
- New reconciliation algorithm introduced in React 16 for async rendering.
- What is concurrent mode in React?
- Allows React to interrupt rendering and prioritize updates.
- What is hydration in React?
- The process of attaching event listeners to server-rendered HTML.
- What is SSR (Server-Side Rendering)?
- Rendering React components on the server for better performance & SEO.
- What is CSR (Client-Side Rendering)?
- Rendering React components in the browser.
- What is the difference between SSR and CSR?
- SSR: Faster first load, better SEO.
- CSR: Faster navigation, heavier initial load.
- What is Next.js?
- A React framework for SSR, routing, API handling, and optimizations.
- What is difference between useEffect and componentWillUnmount?
- useEffect cleanup function mimics componentWillUnmount.
- What is React.StrictMode?
- A wrapper that activates extra checks/warnings for its children.
- What are portals in React?
- Allow rendering children into a DOM node outside the parent hierarchy.
- What is an error boundary?
- A component that catches errors in its child component tree.
- What is forwardRef?
- Passes refs from parent to child components.
- What is prop drilling?
- Passing props through multiple nested components unnecessarily.
- How to avoid prop drilling?
- Context API
- Redux / Zustand / Recoil
- What are synthetic events in React?
- Wrapper around native events for cross-browser compatibility.
- How to optimize React app performance?
- Memoization (React.memo, useMemo, useCallback)
- Code splitting
- Lazy loading
- Virtualization
- Avoid unnecessary re-renders
- What is React.memo?
- A HOC that prevents re-renders if props haven’t changed.
- Difference between React.memo and useMemo?
- React.memo: Memoizes components.
- useMemo: Memoizes values.
- What is windowing or list virtualization?
- Rendering only visible list items (e.g., react-window, react-virtualized).
- What is tree shaking?
- Removing unused code during bundling.
- How to prevent unnecessary re-renders?
- PureComponent
- React.memo
- useCallback
- Key usage in lists
- What is debouncing in React?
- Delaying function execution until a pause in input (e.g., search input).
- What is throttling?
- Limiting function execution to once every interval.
- Difference between useMemo and useRef for caching?
- useMemo: For recalculating values.
- useRef: For persisting mutable values.
- What is hydration mismatch in React?
- When server-rendered markup doesn’t match client-rendered DOM.
- What is bundle splitting?
- Splitting JS bundle into smaller chunks.
- What is code reusability in React?
- Using HOCs, hooks, and render props.
- What is reconciliation optimization?
- Using keys, memoization, and avoiding inline functions.
- What is dynamic import in React?
- Importing modules only when needed using import().
- What is profiling in React?
- Measuring rendering performance using React Profiler API.
- What is Flux?
- An architecture for unidirectional data flow (basis of Redux).
- Difference between Redux and MobX?
- Redux: Strict, predictable, boilerplate-heavy.
- MobX: Simpler, reactive, mutable state.
- What is Recoil?
- State management library for React with atoms/selectors.
- What is Zustand?
- Lightweight state management library using hooks.
- What is Jotai?
- Primitive and flexible state management library.
- What are React DevTools?
- Browser extensions for debugging React apps.
- What is suspense in React?
- For handling asynchronous rendering (e.g., lazy loading).
- What is difference between React Native and React?
- React: Web UIs.
- React Native: Mobile UIs (iOS/Android).
- What is hydration in Next.js?
- The process of converting static HTML to a live React app.
- What is difference between CSR, SSR, and SSG?
- CSR: Client renders everything.
- SSR: Server renders pages at request.
- SSG: Pre-renders at build time.
- What is static site generation (SSG)?
- Building static HTML at compile time (e.g., Next.js getStaticProps).
- What is incremental static regeneration (ISR)?
- Next.js feature to regenerate static pages on demand.
- What is difference between Next.js and CRA?
- CRA: Client-side only.
- Next.js: SSR + SSG + API routes.
- What is hydration warning in React 19?
- Mismatch between server-rendered HTML and client React tree.
- What’s new in React 19?
- Automatic batching
- Concurrent rendering
- useId hook
- startTransition API
Author:
Ambarish Durani
Related Links:
Resume Tips For Software Developers
Do visit our channel to know more: SevenMentor
Ambarish Durani
Expert trainer and consultant at SevenMentor with years of industry experience. Passionate about sharing knowledge and empowering the next generation of tech leaders.
#Technology#Education#Career Guidance