Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { StateCreator } from "zustand";
- export interface AuthSlice {
- isAuthenticated: boolean;
- user: string | null;
- setUser: (username: string) => void;
- logout: () => void;
- }
- export const createAuthSlice: StateCreator<AuthSlice, [], [], AuthSlice> = (set) => ({
- isAuthenticated: false,
- user: null,
- setUser: (username) => (set((_state) => ({ user: username, isAuthenticated: true })), console.log(username)),
- logout: () => (set((_state) => ({ user: null, isAuthenticated: false })), console.log("Logging out...")),
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement