zustand: [devtools] doesn't log actions since v2
When updating from 1.0.7 to 2.2.1, I lose the tracking of all actions in the Redux devtools:
2.2.1
1.0.7
The app works just fine and the store updates correctly when using the app, it just doesn’t log out the commits any more.
Using it like:
import create, { StateCreator } from 'zustand'
import { devtools } from 'zustand/middleware'
export const DefaultStoreState: DefaultStateGetters = {
lastDataUpdate: new Date(),
loading: false,
showDrawer: false,
message: null,
...
}
const store: StateCreator<DefaultState> = (set, get) => ({
...DefaultStoreState,
...
})
export const [useStore, Store] = create<DefaultState>(devtools(store, 'WACHS App Store'))
Any pointers would be appreciated. Let me know if you need more detail and I will update this post.
Cheers & thanks Patrik
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (9 by maintainers)
Hey @pzi,
As you can see on the line https://github.com/react-spring/zustand/blob/master/src/middleware.ts#L33, you need to put
name
of your function that you want to track in Redux dev tools.For example:
I had the same problem too! Hope this help.
For anyone who comes here looking for a quick fix, my solution was to make a type based on the normal StateCreator:
(edited to work properly, my test wasn’t correct)
I think I fixed it fully. #167
Can you try this this @pzi:
@drcmda, should we export this in middleware.ts
do you know what types it would need? im still struggling with TS. i can update and cut a release to fix this.
Hey @dai-shi,
@vuhg Solution works. But however, if we use immer we have to pass args like below otherwise it will not show state updates in the dev tools.
@pzi Your issue
Expected 1 argument but got 2
is caused by this:The
StateCreator
type shouldn’t be used with the middleware’sdevtools
function. Try this:We should export a
DevToolsStateCreator
type in middleware to solve this. We should also defaultname
to'action'
like you said.