React · Senior · Question 59 of 75
A text input at the top of a large page makes the whole page re-render on each keystroke. What is the simplest fix?
- ✓Correct answer: Move the input's state down into a small component (state colocation)
- 2Wrap the whole page in
useMemo - 3Store the input value in a global variable
Explanation
State changes re-render the component that owns it and its children. Keeping fast-changing state close to where it's used limits the work without any memoization.