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....

July 21, 2019 · 3 min

Redux-less context-based useSelector hook that has same performance as React-Redux

Introduction React-Redux provides hooks API with nice abstraction. Especially, useSelector is probaly less misused than mapStateToProps. react-tracked is a library for global state without Redux. This library provides almost compatible hooks API to React-Redux. It’s developed with performance in mind, and it should be as performant as React-Redux, even though it utilizes only React context. See the GitHub repo for more information. https://github.com/dai-shi/react-tracked This post shows benchmark results to convince that it actually is performant in one scenario....

June 16, 2019 · 2 min