Skip to content

Rohitsoni86/Taskify-ts-zustand

Repository files navigation

Taskify-ts-zustand

This is a Todo App With all add , delete & modify tasks with Zustand

Introduction to Zustand

Zustand is a lightweight and flexible state management library for React. It provides a simple API for managing and accessing shared state in your application. It's particularly suited for projects where you need efficient and scalable state management without adding unnecessary complexity.

For your course tutorial website, we’ll use Zustand to manage actions like adding a course, removing a course, toggling course status, and handling data fetching. I'll also include TypeScript to ensure strong typing.

🚀 Effortless State Management with Zustand in Next.js + TypeScript! 🚀

Struggling with React state management? Say hello to Zustand, the lightweight and intuitive library to streamline your state management needs!

In my recent project—a course tutorial website built with Next.js and TypeScript—I leveraged Zustand to manage:

✅ Adding and removing courses ✅ Toggling course statuses ✅ Fetching and displaying courses

🔍 Here's what I loved:

Simple API for defining state and actions. Excellent support for asynchronous data fetching. Flexible and scales well with project complexity.

Install Zustand and Typescript Types:

🔺 npm install zustand

🔺 Create the Zustand Store

🟢 import { create } from 'zustand';

🟢 Simply Go To The Store Folder

🔺 Using Zustand in Next.js/React Components

🟢 import useCourseStore from '@/stores/courseStore'; ===> const addCourse = useCourseStore((state) => state.addCourse); ===> const handleAddCourse = () => { const newCourse = { id: Math.random().toString(36).substring(2, 9), name: courseName, isActive: true, }; addCourse(newCourse); setCourseName(''); };

===> const { courses, toggleCourseStatus, removeCourse } = useCourseStore();

About

This is a Todo App With all add , delete & modify tasks with Zustand

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages