Browse all practice questions for the ReactJS Practice Test. Search by topic, open any question and review its full explanation, then test yourself in the practice quiz.

ReactJS Practice Test course image
More practice questions

These questions are part of the practice quiz. Start practicing

  • In JSX, how is a self-closing tag written?
  • Which technique is commonly used to implement infinite scroll in a React component?
  • To pass info to a component, the values that aren't strings are...
  • Which statement about ReactDOM's purpose is accurate?
  • Which method does a JSX element compile into when using React?
  • Which directory contains assets that will be served directly without additional processing by webpack?
  • What is the role of keys in rendering lists, and what happens if keys are not stable?
  • Passing information: create a method that allows the stateless child component to update the state of the parent component.
  • What are the four phases of a component's lifecycle?
  • Where is React.Component defined?
  • Which of the following statements about JSX is true?
  • What is the purpose of the key attribute in a React list?
  • What is the purpose of the cleanup function returned from useEffect?
  • Which JSX forms are valid for rendering a React component?
  • What is the render props pattern?
  • What is the convention for naming custom hooks?
  • Which two mechanisms provide dynamic information to a React component?
  • Which feature does the service worker file enable?
  • When is it appropriate to wrap a component in React.memo?
  • What is the primary purpose of the render method in a class component?
  • Which statement about ReactDOM.render is accurate?
  • Which statement about event handlers in class components is true?
  • Which of the following best describes how to pass data from a parent to a child in React?
  • In JSX, capitalization is used to distinguish between which two types of elements?
  • Which statement about keys in a list is best practice?
  • Which statement about imports is accurate?
  • Which command bundles the app into static files for production?
  • A component's props is an...
  • Whenever you define an event handler that uses 'this', you need to add
  • style={{ color: 'red' }} - What are the outer curly braces for?
  • JSX element
  • Which approach is recommended for implementing responsive styling in React?
  • What are React applications made out of?
  • A render method must contain what?
  • Which statement about passing props is correct?
  • What is the purpose of render props in React?
  • What is the difference between a React element and a component?
  • If a React component wants to change information stored within itself, it should use ...
  • A React component should use 'state' to store information that the component itself can change.
  • What does the dependencies section in package.json contain?
  • What is the difference between CSS Modules and styled-components?
  • Which of the following is the correct syntax to update component state using setState?
  • How do you create your own component class in React?
  • What does the scripts section specify?
  • What do curly braces in JSX signal?
  • How do you pass a prop to a component in JSX?
  • What is the difference between server-side rendering and client-side rendering in React?
  • What is a React Fragment and when should you use it?
  • What is the purpose of an error boundary in React?
  • When should you use useCallback?
  • Which statement about labeling form controls is accurate?
  • When implementing pagination in React, which state variables are commonly tracked?
  • In a React class component, a render method is defined as which of the following?
  • If your React app uses AJAX to fetch initial data from an API, which lifecycle method is best to use?
  • Which statement about methods inside a class body is correct?
  • In React, onClick is best described as what?
  • Which statement shows how to import React and ReactDOM?
  • If a JSX expression takes up more than one line you must ...
  • To see a component's props object, you use the expression...
  • Which statement accurately describes dynamic information in React components?
  • What is code-splitting and its benefits in React?
  • Which technique helps prevent unnecessary re-renders when providing context values?
  • What are common use cases for useRef?
  • Where must hooks be called?
  • Which is the only property you must include in your React component class?
  • In React, what should the value of a key be?
  • Which is a common React performance anti-pattern?
  • Which command ejects the app and copies build dependencies and configuration into the app directory (and you can't go back)?
  • Which statement about hydration is true?
  • Which statement describes mounting events?
  • Which statement describes the typical pattern for creating a custom hook?
  • Which directory contains the JavaScript that is processed by webpack and is the heart of the React app?
  • Which statement best describes a component?
  • Which command starts the test runner?
  • How do React.lazy and Suspense work together?
  • Why is className used in JSX instead of class?
  • Explain the useTransition hook and how it helps with concurrency.
  • What happens when you call this.setState() in a React component?
  • Where can you place simple calculations and conditional statements inside a render() function?
  • What is the recommended way to ensure 'this' refers to the component inside an event handler?
  • What does the body of a React component class represent?
  • What is the difference between useMemo and useCallback?
  • Explain optimistic UI updates and how to implement them with rollback on error.
  • Which statement best describes a React component?
  • What is true about Error Boundaries in React?
  • Which statement correctly describes controlled components in React forms?
  • Visitors to your site are served those static assets produced by the build. What best describes what is served?
  • style={{ color: 'red' }} - What are the inner curly braces for?
  • Passing information: create a child component that updates its parent's state, which then updates a sibling component.
  • Which statement best describes a React component class?
  • How do you define a new class-based component?
  • Which lifecycle phase denotes that a component has been removed from the UI?
  • How are event listener names written in JSX?
  • Which statement best describes ReactDOM?
  • How to fetch data in a React component and handle cancellation?
  • In a render props pattern, a Mouse component that calls props.render with { x, y } demonstrates what concept?
  • Which property is always available on a component's props to access its children?
  • Who can change a prop value?
  • How do you access a passed-in prop named 'title' inside a component?
  • Which statement is not a valid way to embed a JavaScript expression inside JSX content?
  • Which is an example of a JSX callback function usage?
  • How do you optimize rendering to avoid unnecessary re-renders?
  • ReactDOM.render()'s second argument indicates ...
  • Which statement about the React Context API and useContext is true?
  • What is a SyntheticEvent in React and how does event pooling work?
  • What happens if you omit keys in a list when rendering in React?
  • Which of the following describes 'lifting state up' in React data flow?
  • Which statement about React onClick event listeners is correct?
  • If a component class expects a prop, you can give that component class ...
  • What does the 'private': true setting in package.json prevent?
  • What does diffing refer to in React's virtual DOM?
  • In JSX, how is an expression inside curly braces rendered?
  • Passing information: pass props from a stateful parent component to a stateless child component.
  • Which statement is true about rendering a component with no children in JSX?
  • Which command starts the development server?
  • Why can't you call this.setState() from inside of the .render() method?
  • What is server-side rendering (SSR) and what is hydration in React?
  • How do you define an event handler in React?
  • What does lifting state up mean in React?
  • Props in a React component are intended to store information that can be changed by the component itself.
  • Which of the following describes data that is passed from a parent component to a child component?
  • Which statement about rendering in React is true?
  • The PropTypes concept described is used to describe expected prop types.
  • What is props in React?
  • What is the purpose of the useLayoutEffect hook (and how does it differ from useEffect)?
  • What is a key consequence of ejecting in the setup?
  • Which command generates a boilerplate version of a React application?
  • What happens if you omit the dependencies array in useEffect?
  • Which code pattern sets default props for a React component named MyComponent?
  • Which statement about JSX naming is true?
  • Which token is used for applying CSS classes in JSX?
  • Which file takes care of caching and updating files for offline capability in a React app?
  • this.state should be equal to...
  • What does the dependencies array in useEffect control?
  • What is a primary use case for the useId hook in React?
  • Which statement about ReactDOM is true?
  • Which directory contains the JavaScript that will be processed by webpack and is the heart of the React app?
  • Which statement best describes props and state?
  • Which statement best describes the public directory's purpose in a React app?
  • How do you expose imperative methods from a child component to its parent using refs?
  • Which statement about higher-order components is accurate?
  • What is the difference between useEffect cleanup function and componentWillUnmount?
  • The lifecycle category that includes render() is?
  • Which of the following describes the rules for using React hooks?
  • To make a component have state, you should...
  • In React, what is state?
  • Which feature do class components have that functional components historically did not, but can be mimicked with hooks?
  • Which statement is true about React.Component in a typical module import?
  • What is the purpose of keys in lists?
  • A component changes its state by calling the function
  • To read a component's state, use the expression
  • Which statement correctly describes how to access the props object inside a React class component?
  • What is the term for the attributes passed to a component to configure it?
  • Which naming style is recommended for class names in React components?
  • What is a React portal primarily used for?
  • What does the JSX compiler produce for JSX?
  • A React component should use 'props' to store information that can be changed, but can only be changed by a different component.
  • When should you use useCallback?
  • React components always have to call ________ for constructors to be set up properly.
  • In a React component, why is calling this.setState() inside render() discouraged?
  • Which of the following expresses the conventional naming for event listener attributes in JSX?
  • Which statement best describes accessibility considerations in React?
  • Can you access variables declared outside a JSX expression inside the JSX block?
  • Where is the initial state typically assigned in a class-based component?
  • A JSX expression must have exactly one outermost element.
  • Which statement describes uncontrolled components in React forms?
  • Which of the following best describes how JSX elements relate to components?
  • Which statement about JSX attributes is true?
  • Which practice best supports accessibility in React?
  • How should you update state when the new state depends on the previous state?
  • What is the difference between stateful and stateless components?
  • What term describes information that can change over time in a component?
  • Which statement best describes how data can be passed into a component as props?
  • What is the purpose of keys in a list in React?
  • What is the purpose of dangerouslySetInnerHTML in React, and when should you use it?
  • If you do not bind an event handler that uses 'this', what is a common consequence?
  • What does ReactDOM.render() first argument typically contain?
  • When should you use useMemo?
  • What is the difference between props and state?
  • What does npm run build generate for deployment?
  • What is a recommended approach to improve user experience while data is loading from an API?
  • What pattern helps handle errors in async data fetching within components?
  • What is snapshot testing in React, and what are its typical pros and cons?
  • Where are event handlers typically defined in a class component?
  • Which statement is true about state in a component?
  • Which sequence describes testing a React component with React Testing Library?
  • What is a common drawback of snapshot testing?
  • How would you implement debouncing in a React input to limit API calls?
  • The methods imported from 'react' do what?
  • Besides props and state, every value used in a component should...
  • Render() belongs to two lifecycle categories: mounting and ...
  • Which statement about React components is true?
  • React uses a tool called which transforms the directories and files into static assets?
  • Diffing refers to which process?
  • Which statement best describes a JSX element?
  • What is the role of index.html in a typical React app?
  • What is the primary purpose of a custom hook in React?
  • What is a recommended approach to reduce re-renders caused by context value changes?
  • What is the purpose of the defaultProps property in a React component?
  • In a render props pattern, what does a child component typically do with a function prop named render?
  • What is the virtual DOM?
  • Which statement is correct about updating state with useState when the new state depends on the previous state?
  • What is JSX in React?
  • Which statement about rendering in React is true?
  • What naming convention should component class names use in React?
  • Which statement best contrasts render props with higher-order components?
  • this.props refers to that storage object. At the same time, each piece of passed-in information is called...
  • If a component has only one child, what does this.props.children return?
  • In React, how is onClick typically attached to a component instance in JSX?
  • What is a key characteristic of the virtual DOM?
  • A component 'mounts' when ...
  • If a component has more than one child between its JSX tags, what does this.props.children contain?
  • What is the difference between props drilling and using contextual data in React?
  • In the example <Button onClick={this.handleClick} />, what is assigned to the onClick prop?
  • Which file configures how the web app behaves when added to an Android user's home screen?
  • What is the difference between functional components with hooks and class components?
  • You cannot call this.setState from the body of this update lifecycle method.
  • What is React.StrictMode and why is it used during development?
Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy