mirror of
https://github.com/pmndrs/zustand.git
synced 2025-12-08 19:45:52 +00:00
docs: expose enabled devtools options in the documentation (#1326)
This commit is contained in:
parent
3e311520d5
commit
d60f0cca7a
@ -379,6 +379,8 @@ import { devtools } from 'zustand/middleware'
|
||||
const useStore = create(devtools(store))
|
||||
// Usage with a redux store, it will log full action types
|
||||
const useStore = create(devtools(redux(reducer, initialState)))
|
||||
// Disabling devtools (for instance in production build)
|
||||
const useStore = create(devtools(store, { enabled: false }))
|
||||
```
|
||||
|
||||
devtools takes the store function as its first argument, optionally you can name the store with a second argument: `devtools(store, "MyStore")`, which will be prefixed to your actions.
|
||||
|
||||
@ -430,6 +430,12 @@ If an action type is not provided, it is defaulted to "anonymous". You can custo
|
||||
devtools(..., { anonymousActionType: 'unknown', ... })
|
||||
```
|
||||
|
||||
If you wish to disable devtools (on production for instance). You can customize this setting by providing the `enabled` parameter:
|
||||
|
||||
```jsx
|
||||
devtools(..., { enabled: false, ... })
|
||||
```
|
||||
|
||||
## React context
|
||||
|
||||
The store created with `create` doesn't require context providers. In some cases, you may want to use contexts for dependency injection or if you want to initialize your store with props from a component. Because the normal store is a hook, passing it as a normal context value may violate rules of hooks.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user