From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js

Unlock this course with a free trial

Join today to access over 25,200 courses taught by industry experts.

Zustand code example

Zustand code example

Welcome back. For the ZooStand example, we are going to follow in this video. I have created a new project with name ZooStand app. I have installed Tailwind and I have deleted all the unnecessary files we get as a startup project. So, this is a plain project without any code. We are going to go in the terminal. Inside here, we are going to install zustand first by npm install zustand. Once this is installed, I am going to go in the code base. Inside the source folder, I'm going to add another folder called store. Inside this folder, I'm going to have a file and I'm going to call it counterstore.ts. Now first of all, let's have an interface for counter state. this we can have a number, then we can have an increment function which will take a number, it will tell how much we want to increment the counter. Similarly, we can have a decrement function, it will also be a number for how much we want to decrement the counter width and then we can have a resend function, then we can have a…

Contents