1. 4
    Define Actions in a Zustand-like Store to Modify React State
    2m 16s

Define Actions in a Zustand-like Store to Modify React State

InstructorDaishi Kato

Share this video with your friends

Send Tweet

At this point in our code, we have working module state that is similar to Zustand. If you look closely at the code you’ll notice that we are defining actions in our components. This works for some but you might want to define those actions when you create a store.

We will modify createStore to accept a createState function and use that function to initialize and update our state. This allows us to define actions while creating a store. We can use those defined actions in our components without having to implement any logic inline.