React · Junior · Question 72 of 75

Two <Counter /> components are rendered on the page. Do they share state?

Explanation

State belongs to a position in the tree, not to the component function. To share it, lift it to a common parent or use context/a store.

Further reading

Problem with a question

React · Junior · question 72

Test yourself

Take the React · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz