Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@bishalk21
Copy link

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;
},
}));

@pmndrs pmndrs locked and limited conversation to collaborators Mar 28, 2024
@dai-shi dai-shi converted this issue into discussion #2444 Mar 28, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant