Compare commits
1 Commits
master
...
cfe5b13362
| Author | SHA1 | Date | |
|---|---|---|---|
| cfe5b13362 |
@@ -26,7 +26,7 @@ createStore('counter', {
|
||||
});
|
||||
```
|
||||
|
||||
## `<StateProvider />`
|
||||
## <StateProvider />
|
||||
|
||||
A React component used to provide all of the created stores as context. You can wrap your entire app in this component to get access to all of the stores that exist. Alternatively, the component takes a `names` prop string that you can use to control which store providers are used. The string should be a comma-delimited list of stores by name.
|
||||
|
||||
@@ -36,12 +36,12 @@ A React component used to provide all of the created stores as context. You can
|
||||
</StateProvider>
|
||||
```
|
||||
|
||||
## `useStore(name)`
|
||||
## useStore(name)
|
||||
|
||||
A React [hook](https://reactjs.org/docs/hooks-reference.html) to access the store's state value, and methods to read and update it. The hook returns an object with the following properties:
|
||||
|
||||
Property | Description
|
||||
-------- | -----------
|
||||
-- | --
|
||||
`state` | The current state value of the store.
|
||||
`commit(name, ...args)` | Executes mutations, which synchronously change the state and update context, causing components that use the context to re-render.
|
||||
`dispatch(name, ...args)` | Fires actions, which perform async work and use mutations to update state. Returns a Promise that resolves when the action is complete.
|
||||
|
||||
Reference in New Issue
Block a user