docs: Fix TypeScript docs for using subscribe with selector (#876)

This commit is contained in:
Paras Sanghavi 2022-03-20 20:09:30 -07:00 committed by GitHub
parent da781a2577
commit fe06e13187
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -217,8 +217,8 @@ const unsub5 = useStore.subscribe(state => state.paw, console.log, { fireImmedia
<summary>How to type store with `subscribeWithSelector` in TypeScript</summary>
```ts
import create, { GetState, SetState } from 'zustand'
import { StoreApiWithSubscribeWithSelector, subscribeWithSelector } from 'zustand/middleware'
import create, { Mutate, GetState, SetState, StoreApi } from 'zustand'
import { subscribeWithSelector } from 'zustand/middleware'
type BearState = {
paw: boolean
@ -229,7 +229,7 @@ const useStore = create<
BearState,
SetState<BearState>,
GetState<BearState>,
StoreApiWithSubscribeWithSelector<BearState>
Mutate<StoreApi<BearState>, [["zustand/subscribeWithSelector", never]]>
>(subscribeWithSelector(() => ({ paw: true, snout: true, fur: true })))
```