DEV Community

Wonuola
Wonuola

Posted on

React Interview Questions

Question 1: Why should you not copy the values of props into a component's state?

Answer: It will create two instances of the same state that can become out of sync.

Question 2: What is not a rule for React Hooks?

Answer: Hooks can be called in Class or Function components

Question 3: What is a common use case for ref?

Answer: To access the DOM node.

Question 4: How can you optimize performance for a function component that always renders the same way?

Answer: Wrap it in a React.memo higher order component

Question 5: A copy of the 'real' DOM that is kept in memory is called what?

Answer: Virtual DOM

BONUS
Question: What is the children prop?

Answer: A property that lets you nest components in other components

Let me know if this helped ;)

Top comments (1)

Collapse
 
orashus profile image
Rash Edmund Jr

nice write up 👍🏾