mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
fix(docs): Fix 'State' declaration position (#1438)
* Fix 'State' declaration position * Update auto-generating-selectors.md Update pr with review * Update auto-generating-selectors.md
This commit is contained in:
parent
bf9d0922fe
commit
47b2b64e52
@ -14,13 +14,13 @@ However, writing these could be tedious. If that is the case for you, you can au
|
||||
## create the following function: `createSelectors`
|
||||
|
||||
```typescript
|
||||
import { State, StoreApi, UseBoundStore } from 'zustand'
|
||||
import { StoreApi, UseBoundStore } from 'zustand'
|
||||
|
||||
type WithSelectors<S> = S extends { getState: () => infer T }
|
||||
? S & { use: { [K in keyof T]: () => T[K] } }
|
||||
: never
|
||||
|
||||
const createSelectors = <S extends UseBoundStore<StoreApi<State>>>(
|
||||
const createSelectors = <S extends UseBoundStore<StoreApi<object>>>(
|
||||
_store: S
|
||||
) => {
|
||||
let store = _store as WithSelectors<typeof _store>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user