1. 3
    Implement Zustand State Selectors in React to Prevent Unneeded Rerenders
    2m 41s

Implement Zustand State Selectors in React to Prevent Unneeded Rerenders

InstructorDaishi Kato

Share this video with your friends

Send Tweet

We have to functions right now. createStore that creates module state and useStore that consumes the module state that we created.

The logic is working as expected. State is being properly shared to the components that need it while still isolated from the rest of the app. The issue now is that we have extra re-renders in our application. Each component will rerender when any state changes

To fix this, we'll implement a selector function that will peek the value that you need out of state. This way only the components that depend on the value that is changed will re-render.