Crack the Frontend Round: 20 React.js Questions You Must Know Quiz

  1. JSX Syntax

    What is JSX primarily used for in React?

    1. Defining component logic
    2. Describing the user interface
    3. Managing application state
    4. Handling events
  2. Component Type

    Which type of React component uses the 'this' keyword to access props and state?

    1. Functional components
    2. Class components
    3. Arrow functions
    4. Stateless Components
  3. Props Definition

    How do you pass data from a parent component to a child component in React?

    1. Using state
    2. Using props
    3. Using context
    4. Using refs
  4. useState Hook Usage

    What does the useState hook return?

    1. Only the state variable
    2. Only the function to update the state
    3. A pair containing the state variable and a function to update it
    4. Nothing
  5. useEffect Dependency Array

    What is the purpose of the dependency array in the useEffect hook?

    1. To specify the initial state
    2. To control when the effect runs
    3. To define the cleanup function
    4. To declare global variables
  6. Event Handling

    How do you prevent the default behavior of an event in React?

    1. Using event.stopDefault()
    2. Using event.preventDefault()
    3. Using event.stopPropogation()
    4. Using event.stopImmediatePropagation()
  7. Conditional Rendering

    Which operator is commonly used for inline conditional rendering in JSX?

    1. For loop
    2. If statement
    3. Ternary operator
    4. Switch statement
  8. Lists and Keys

    What is the purpose of the 'key' prop when rendering lists of components in React?

    1. To style the list items
    2. To uniquely identify each list item
    3. To sort the list items
    4. To hide the list items
  9. Component Lifecycle Methods

    Which lifecycle method is called after a component's output has been rendered to the DOM?

    1. componentWillMount
    2. componentDidMount
    3. componentWillUpdate
    4. componentDidUpdate
  10. Lifting State Up

    What does 'lifting state up' mean in React?

    1. Moving state to a child component
    2. Moving state to a parent component
    3. Removing state from the application
    4. Duplicating the state across components
  11. React Router Basics

    Which React Router component is used to navigate between different routes?

    1. u003CSwitchu003E
    2. u003CRouteu003E
    3. u003CLinku003E
    4. u003CRedirectu003E
  12. Controlled vs Uncontrolled

    In React, what is a controlled component?

    1. A component that doesn't use state
    2. A component whose value is controlled by React state
    3. A component that only renders static content
    4. A component without any event handlers
  13. useContext Hook

    What is the primary purpose of the useContext hook?

    1. To manage local component state
    2. To access context values within functional components
    3. To create reusable logic
    4. To optimize rendering performance
  14. useRef Hook

    What can the useRef hook be used for?

    1. To manage component state
    2. To persist values between renders without causing re-renders
    3. To access context values
    4. To define event handlers
  15. React Performance Optimizations

    Which technique can be used to prevent unnecessary re-renders of components?

    1. ForceUpdate()
    2. Using shouldComponentUpdate or React.memo
    3. Using componentWillMount
    4. Using componentDidUpdate
  16. Virtual DOM

    What is the primary function of the Virtual DOM in React?

    1. To directly manipulate the real DOM
    2. To provide a lightweight copy of the real DOM for efficient updates
    3. To replace the real DOM entirely
    4. To store application state
  17. Code Splitting

    What is the purpose of code splitting in React?

    1. To reduce the size of individual components
    2. To divide the application into smaller bundles for faster initial load times
    3. To improve code readability
    4. To simplify component composition
  18. Error Boundaries

    What is the purpose of error boundaries in React?

    1. To prevent JavaScript errors from occurring
    2. To gracefully handle errors and prevent the entire application from crashing
    3. To debug code more efficiently
    4. To automatically fix errors in the code
  19. Custom Hooks

    What is a custom hook in React?

    1. A pre-built React component
    2. A JavaScript function that starts with 'use' and can call other hooks
    3. A special type of event handler
    4. A method for managing global state
  20. Lazy Loading

    What is lazy loading and how does it benefit React applications?

    1. A technique to load all components at once for faster rendering.
    2. A technique to defer loading of non-critical resources at page load time, improving initial load time.
    3. A technique that is only useful for class components.
    4. A technique to load all images before the rest of the components.