Effortless render optimization with state usage tracking with React hooks
Introduction React useContext is very handy to avoid prop drilling. It can be used to define global state or shared state that multiple components in the tree can access. However, useContext is not specifically designed for global state and there’s a caveat. Any change to context value propagates all useContext to re-render components. This post shows some example code about the problem and the solution with state usage tracking. Problem Let’s assume a person object as a state....