React Interview Questions

Want to become an expert in cracking React interview questions/ReactJS interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public React Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.

1. Focus

React Components Public New

The TextInput component renders an input element in the DOM and accepts a ref that is forwarded to that input element. Finish the FocusableInput component:

  • The component should accept a focused prop.
  • When the focused prop is changed from false to true, and the input is not focused, it should receive the focus.
  • If on mounting the focused prop is true, the input should receive the focus.
HTML5, CSS3, React v16  

  •   The focused property has an initial state of true: Wrong answer
  •   Changing the focused prop from false to true focuses the input: Wrong answer

2. Todo List

React Event handling Public New

Write a TodoList component that expects an items prop, and a list of objects, each with text and done properties.

TodoList also accepts an onItemClick function prop, which should be called when a user clicks an item in the list, if the item is not marked as done. Otherwise, the onItemClick should not be called and the click event itself should not be propagated further. The function should be called with the item object from the items list as the first parameter and the event as the second parameter.

HTML5, CSS3, React v16  

  •   Clicking on a not done item should trigger onItemClick: Wrong answer
  •   Clicking on a done item should not trigger onItemClick or a parent click: Wrong answer

3. Change Username

React Reference Hook Public New

This application should allow the user to update their username by inputting a custom value and clicking the button.

The Username component is finished and should not be changed, but the App component is missing parts. Finish the App component so that the Username component displays the inputted text when the button is clicked.

The App component should use the React.useRef Hook to pass the input to the Username component for the input element and for the Username component.

For example, if the user inputs a new username of "John Doe" and clicks the button, the div element with id root should look like this:

<div><button>Change Username</button><input type="text"><h1>John Doe</h1></div>
HTML5, CSS3, React v16  

  •   Example case: Wrong answer
  •   Clicking on the button updates the username from the input: Wrong answer
  •   Reference Hook was used to update username: Wrong answer

4. Grocery App

React Components Managing state Public New

You have a GroceryApp class, which receives a list of products, each one with name and votes. The app should render an unordered list, with a list item for each product. Products can be upvoted or downvoted.

By appropriately using React state and props, implement the upvote/downvote logic. Keep the state in the topmost component, while the Product component should accept props.

For example, passing the following array as products prop to GroceryApp [{ name: "Oranges", votes: 0 }, { name: "Bananas", votes: 0 }] and clicking the '+' button next to the Oranges should result in HTML like:

<div id="root">
      <span>Oranges</span> - <span>votes: 1</span><button>+</button> <button>-</button>
      <span>Bananas</span> - <span>votes: 0</span><button>+</button> <button>-</button>
HTML5, CSS3, React v16  

  •   Example case: Wrong answer
  •   GroceryApp should render a list item for each product: Wrong answer
  •   Clicking on "+" button increases product votes: Wrong answer
  •   Clicking on "-" button decreases product votes: Wrong answer

If you feel ready, take one of our timed public React Interview Questions tests:
  • HTML/CSS and React Online Test (Easy)
  • HTML/CSS, JavaScript, and React Online Test (Easy)
  • HTML/CSS, React, and Node.js Online Test (Easy / Hard)
  • HTML/CSS, React, Node.js, and SQL Online Test (Easy / Hard)
  • React Online Test (Easy)
Not exactly what you are looking for? Go to our For Jobseekers section.