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
From the course: Build Modern Web Apps with React, Hooks, State Management, and APIs Using Vite or Next.js
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Introduction and recap: Local state and global state7m 6s
-
(Locked)
useState and useContext: Recap and pitfalls5m 56s
-
(Locked)
Problems solved by global state libraries7m 26s
-
(Locked)
Problems without global state: Summary5m 13s
-
(Locked)
Lifting state up: Recap3m 17s
-
(Locked)
Advanced scenario 1: Multiple dependents6m 46s
-
(Locked)
Advanced scenario 2: Derived state8m 14s
-
(Locked)
Summary2m 8s
-
(Locked)
Context API: Recap4m 48s
-
(Locked)
Best practices2m 48s
-
(Locked)
Performance considerations3m 35s
-
(Locked)
Introduction to Redux5m 6s
-
(Locked)
Setting up Redux project4m 17s
-
(Locked)
Setting up types for action6m 1s
-
(Locked)
Setting up actions for counter6m 18s
-
(Locked)
Setting up reducer for counter6m 52s
-
(Locked)
Setting up Redux store8m 20s
-
(Locked)
Counter component11m 50s
-
(Locked)
Introduction to RTK2m 29s
-
(Locked)
Real-world analogy: Key concepts3m 58s
-
(Locked)
Store setup14m 36s
-
(Locked)
Reducer setup8m 25s
-
(Locked)
Custom hook and component setup11m 4s
-
(Locked)
Plug new store and dev tools demo5m 51s
-
(Locked)
Introduction to async thunk in RTK2m 44s
-
(Locked)
Explanation of code with async thunk and slice5m 8s
-
(Locked)
Fetch users function11m 7s
-
(Locked)
User slice setup7m 19s
-
(Locked)
Users component and demo8m 25s
-
(Locked)
RTK Query: Introduction2m 50s
-
(Locked)
Reselect usage and demo7m 37s
-
(Locked)
Caching and refetching comparison6m 41s
-
(Locked)
useSelector problems7m 22s
-
(Locked)
Generated hooks and example7m 8s
-
(Locked)
Benefits of Reselect1m 39s
-
(Locked)
Custom middleware: Introduction8m 15s
-
(Locked)
Analytic middleware example2m 19s
-
(Locked)
Benefits and summary1m 31s
-
(Locked)
Challenges with large apps2m 42s
-
(Locked)
Domain-based example2m 24s
-
(Locked)
Benefits of structured stores1m 58s
-
(Locked)
Redux alternatives3m 44s
-
(Locked)
Zustand code example8m 15s
-
(Locked)
Jotai code example11m 41s
-
(Locked)
Recoil code example14m 39s
-
(Locked)
Comparison: When to use which3m 17s
-
(Locked)
Introduction to server state management4m 28s
-
(Locked)
TanStack React Query example4m 25s
-
(Locked)
SWR (Stale-While-Revalidate) example3m 18s
-
(Locked)
Comparison between TanStack and SWR4m 34s
-
(Locked)
Project overview6m 27s
-
(Locked)
Project setup and installations5m 13s
-
(Locked)
Store setup and API5m 31s
-
(Locked)
Products list component6m 52s
-
(Locked)
Product card component7m 49s
-
(Locked)
Cart slice8m 48s
-
(Locked)
Cart component19m 5s
-
(Locked)
App component6m 50s
-
(Locked)
Server-side sync5m 12s
-
(Locked)
-