React · Senior · Question 71 of 75
Why is storing JSX elements in state usually a bad idea?
- ✓Correct answer: Elements capture props at creation time and get stale; store data in state and build JSX during render
- 2JSX can't be stored in variables
- 3It breaks server rendering only
Explanation
Data in state plus rendering from it keeps the UI consistent with the latest props and context. Elements in state also complicate serialization and debugging.