You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Argument of type '(state: ClientStore) => Client | undefined' is not assignable to parameter of type 'ClientStore | Partial<ClientStore> | ((state: ClientStore) => ClientStore | Partial<ClientStore>)'. Type '(state: ClientStore) => Client | undefined' is not assignable to type '(state: ClientStore) => ClientStore | Partial<ClientStore>'. Type 'Client | undefined' is not assignable to type 'ClientStore | Partial<ClientStore>'. Type 'undefined' is not assignable to type 'ClientStore | Partial<ClientStore>'.ts(2345)
#2443
Closed
bishalk21 opened this issue
Mar 28, 2024
· 0 comments
HELP ME:
import create from "zustand";
import { Client } from "./types";
interface ClientStore {
clients: Client[];
addClient: (client: Client) => void;
getClientById: (clientId: string) => Client | null;
}
export const useClientStore = create((set) => ({
clients: [],
addClient: (client) =>
set((state) => ({ clients: [...state.clients, client] })),
getClientById: (clientId) => {
const client = set((state) =>
state.clients.find((c: Client) => c.id === clientId)
);
return client || null;
},
}));
The text was updated successfully, but these errors were encountered: