1. 2
    Extract Module Logic (like Zustand) into a Custom React Hook
    1m 40s

Extract Module Logic (like Zustand) into a Custom React Hook

InstructorDaishi Kato

Share this video with your friends

Send Tweet

We have two components that use the same store. They display the data and update the store when a button is clicked. The logic in each component is the same and can be extracted into a custom hook

In this lesson, we'll extract the store logic into a useStore hook and use that custom hook like you would any other React hook. Then we'll extend the behavior of the hook to accept a function to update the previous state value.