← All React Flashcard Decks

Mixed Deck — All React Topics Flashcards

100 cards from real React practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.

Read the first 20 Mixed Deck — All React Topics flashcards as text
  1. How can useRef help avoid stale closures in event handlers?

    Answer: By storing the latest value in ref.current so the handler always reads up-to-date data

    Storing the current value in a ref lets an event handler read the latest value without being recreated on every render.

  2. Which of the following is NOT a rule for React Hooks?

    Answer: Hooks can only be called at the top level of a component

    React Hooks are specifically designed to be used exclusively within React function components. They cannot be called inside class components, as class components manage state and side effects using `this.state` and lifecycle methods. This fundamental rule ensures that Hooks provide a consistent and predictable way to use React features without the complexities of classes.

  3. How does React determine which useState call corresponds to which state variable across renders?

    Answer: By the order hooks are called

    React tracks hooks by their call order, which is why hooks must always be called in the same order.

  4. What is a trailing stop order?

    Answer: A stop-loss that automatically adjusts upward as the price rises, locking in profits while protecting against reversals

    Trailing stops move with the price in a favorable direction but stay fixed when the price moves against you, automatically locking in gains.

  5. What naming convention must all custom hooks follow?

    Answer: They must start with 'use'

    Custom hooks must start with 'use' so React's linter can enforce the Rules of Hooks for them.

  6. Which library is most commonly used for form state management and validation in React?

    Answer: Formik

    Formik is one of the most popular React form libraries, providing utilities for handling form state, validation, and submission with minimal boilerplate.

  7. Which of the following can a custom hook contain?

    Answer: Any combination of built-in hooks and logic

    A custom hook is just a JavaScript function that can call any built-in or custom hooks internally.

  8. What is the purpose of the `onBlur` event in React form handling?

    Answer: To trigger validation or actions when a user leaves an input field

    onBlur fires when an element loses focus, making it ideal for triggering field-level validation after the user has finished entering input.

  9. What is the significance of pre-market and after-hours trading?

    Answer: Trading that occurs outside regular market hours, often with lower volume, wider spreads, and higher volatility

    Extended hours trading allows reactions to news and earnings before and after the regular session, but typically with less liquidity and wider bid-ask spreads.

  10. What is hydration in React?

    Answer: The process of attaching React event listeners to server-rendered HTML, making it interactive on the client

    Hydration takes the static HTML from server-side rendering and attaches React's event handlers and state management, making the page interactive.

  11. What does useReducer return?

    Answer: A [state, dispatch] tuple

    useReducer returns a [state, dispatch] pair, where dispatch sends actions to the reducer.

  12. How does a usePrevious custom hook work?

    Answer: It stores the current value in a ref after each render and returns the previous render's value

    A useEffect inside the hook updates the ref after each render, so the ref holds the value from the previous render.

  13. What is an 'uncontrolled' component in React?

    Answer: A component where the DOM manages its own form data internally

    In uncontrolled components, the DOM itself maintains the form data, and you access it via refs rather than React state.

  14. What is the best practice for displaying form validation errors in React?

    Answer: Store error messages in state and display them conditionally near the field

    Storing error messages in state and rendering them conditionally near the relevant fields gives users immediate, contextual feedback while keeping validation logic in React.

  15. Which of these is a valid way to lazily initialize state?

    Answer: useState(() => expensiveComputation())

    Passing a function to useState causes it to run only on the initial render, avoiding repeated expensive calls.

  16. Why can't you directly make the useEffect callback an async function?

    Answer: Async functions return a Promise, but useEffect expects a cleanup function or nothing

    useEffect expects the callback to return either undefined or a cleanup function, not a Promise.

  17. What is component composition in React?

    Answer: Building complex UIs by combining simpler components together, passing children and props

    Composition means building complex components by combining simpler ones, rather than using inheritance. This is React's primary pattern for code reuse.

  18. What is the children prop?

    Answer: A property that lets you set an object as a property

    The `children` prop in React is a special property that allows components to receive and render content passed between their opening and closing tags. While its primary use is for component composition and nesting, the value of the `children` prop itself can be a JavaScript object, such as a React element object, an array of elements, or even a string. Therefore, it functions as a property that can hold an object representing the nested content.

  19. In React, which of the following is also referred to as the Flux initialization action?

    Answer: Index.jsx, the entry point of the application

    In many React applications, `index.jsx` (or `index.js`) serves as the main entry point where the entire application is bootstrapped and rendered into the DOM. This file often contains the initial setup for the application, including the first render of the root React component and potentially the initialization of the Flux architecture or dispatching initial actions. It is the starting point from which the application's lifecycle begins.

  20. What is lazy loading in React?

    Answer: Loading components or code only when they are needed rather than all upfront, improving initial load time

    React.lazy() enables code splitting by loading components dynamically when they are first rendered, reducing the initial bundle size.

Written and edited by , founder of Practice Test Geeks, with AI assistance. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Editorial policy