Skip to content

Commit

Permalink
use ReadonlyStoreApi in useStore
Browse files Browse the repository at this point in the history
  • Loading branch information
holic authored Jun 4, 2024
1 parent 018358c commit 2eeee19
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ let didWarnAboutEqualityFn = false

const identity = <T>(arg: T): T => arg

export function useStore<S extends WithReact<StoreApi<unknown>>>(
export function useStore<S extends WithReact<ReadonlyStoreApi<unknown>>>(
api: S,
): ExtractState<S>

export function useStore<S extends WithReact<StoreApi<unknown>>, U>(
export function useStore<S extends WithReact<ReadonlyStoreApi<unknown>>, U>(
api: S,
selector: (state: ExtractState<S>) => U,
): U
Expand All @@ -44,14 +44,14 @@ export function useStore<S extends WithReact<StoreApi<unknown>>, U>(
* @deprecated The usage with three arguments is deprecated. Use `useStoreWithEqualityFn` from 'zustand/traditional'. The usage with one or two arguments is not deprecated.
* https://github.com/pmndrs/zustand/discussions/1937
*/
export function useStore<S extends WithReact<StoreApi<unknown>>, U>(
export function useStore<S extends WithReact<ReadonlyStoreApi<unknown>>, U>(
api: S,
selector: (state: ExtractState<S>) => U,
equalityFn: ((a: U, b: U) => boolean) | undefined,
): U

export function useStore<TState, StateSlice>(
api: WithReact<StoreApi<TState>>,
api: WithReact<ReadonlyStoreApi<TState>>,
selector: (state: TState) => StateSlice = identity as any,
equalityFn?: (a: StateSlice, b: StateSlice) => boolean,
) {
Expand Down

0 comments on commit 2eeee19

Please sign in to comment.