State Management · Senior · Question 58 of 75
How do you react to very frequent Zustand changes (e.g. pointer position at 60fps) without re-rendering?
- ✓Correct answer: Subscribe with
store.subscribein an effect and update a DOM node or ref directly (transient updates) - 2Select the value with
useStoreand memoize the component - 3Use
setIntervalto readgetState()
Explanation
Re-rendering React components at that rate is expensive. Writing to a ref or style directly keeps the store as the source of truth without render cost.