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) #2444
Replies: 1 comment
-
@bishalk21 would you mind sharing us a minimal repro on stackblitz? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
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;
},
}));
Beta Was this translation helpful? Give feedback.
All reactions