React · Junior · Question 72 of 75
Two <Counter /> components are rendered on the page. Do they share state?
- ✓Correct answer: No - each rendered instance has its own state
- 2Yes - state is shared by all instances of a component
- 3Only if they have the same
key
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.