-
The docs says do this: const repoStore = createStore('repo')({
name: 'zustandX',
stars: 0,
middlewares: ['immer', 'devtools', 'persist']
}) That does not work, so I took a look at the source code. You are supposed to set devtools in a second options parameter to createStore: export const createStore =
<TName extends string>(name: TName) =>
<T extends State>(
initialState: T,
options: CreateStoreOptions<T> = {}
): StoreApi<TName, T, StateActions<T>> => {
const {
middlewares: _middlewares = [],
devtools,
persist,
immer,
} = options; So something along the lines of: return createStore("UserData")<UserData>(defaultValues, {
devtools: {
// What values to put in here though? The docs doesn't say
},
// This does not work:
// middlewares: ["devtools"],
}); It expects: interface CreateStoreOptions<T extends State> {
/**
* Zustand middlewares.
*/
middlewares?: any[];
/**
* Devtools middleware options.
*/
devtools?: DevtoolsOptions;
/**
* Immer middleware options.
*/
immer?: ImmerOptions;
/**
* Persist middleware options.
*/
persist?: PersistOptions<Partial<T>>;
}
export interface DevtoolsOptions extends Config {
name?: string;
enabled?: boolean;
anonymousActionType?: string;
store?: string;
} What's a valid entry for |
Beta Was this translation helpful? Give feedback.
Answered by
simon3495
Aug 23, 2024
Replies: 1 comment 1 reply
-
You'll need to dig a bit into zustand. PR's welcome to improve the docs. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Figured it out, the name is simply the name of the store, and then you just put
enabled: true
, and then you can see the zustand state in the redux dev tools. So: