mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
Add getInitialState as part of api utilities (#2729)
This commit is contained in:
parent
0a4f9d0f71
commit
5ebe8606d6
@ -37,8 +37,8 @@ createStore<T>()(stateCreatorFn: StateCreator<T, [], []>): StoreApi<T>
|
||||
|
||||
#### Returns
|
||||
|
||||
`createStore` returns a vanilla store that exposes API utilities, `setState`, `getState` and
|
||||
`subscribe`.
|
||||
`createStore` returns a vanilla store that exposes API utilities, `setState`, `getState`,
|
||||
`getInitialState` and `subscribe`.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@ -40,10 +40,10 @@ createWithEqualityFn<T>()(stateCreatorFn: StateCreator<T, [], []>, equalityFn?:
|
||||
|
||||
#### Returns
|
||||
|
||||
`createWithEqualityFn` returns a React Hook with some API utilities, `setState`, `getState`, and
|
||||
`subscribe`, attached like `create`. It lets you return data that is based on current state,
|
||||
using a selector function, and lets you skip re-renders using an equality function. It should take
|
||||
a selector function, and an equality function as arguments.
|
||||
`createWithEqualityFn` returns a React Hook with API utilities attached, just like `create`. It
|
||||
lets you return data that is based on current state, using a selector function, and lets you skip
|
||||
re-renders using an equality function. It should take a selector function, and an equality function
|
||||
as arguments.
|
||||
|
||||
### Updating state based on previous state
|
||||
|
||||
|
||||
@ -37,9 +37,9 @@ create<T>()(stateCreatorFn: StateCreator<T, [], []>): UseBoundStore<StoreApi<T>>
|
||||
|
||||
#### Returns
|
||||
|
||||
`create` returns a React Hook with some API utilities, `setState`, `getState`, and `subscribe`,
|
||||
attached. It lets you return data that is based on current state, using a selector function. It
|
||||
should take a selector function as its only argument.
|
||||
`create` returns a React Hook with API utilities, `setState`, `getState`, `getInitialState` and
|
||||
`subscribe`, attached. It lets you return data that is based on current state, using a selector
|
||||
function. It should take a selector function as its only argument.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user