Redux DevTools usage? #679
-
https://valtio.pmnd.rs/docs/api/utils/devtools import { devtools } from 'valtio/utils'
const state = proxy({ count: 0, text: 'hello' })
const unsub = devtools(state, { name: 'state name', enabled: true }) ☝️ I don't understand this. I tried to use: import { devtools } from 'valtio/utils'
const state = devtools(proxy({ count: 0, text: 'hello' })) I expected DevTools to work but it didn't. What is the usage for DevTools in Valtio? 🤔 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I guess you literally just do |
Beta Was this translation helpful? Give feedback.
-
Here's how I'm doing it in my Vite / React app. If you're not in an ESM module you can replace the export const cartState = proxy<CartState>({
...defaultState,
});
if (import.meta.env.DEV) {
const { devtools } = await import("valtio/utils");
devtools(cartState, { name: "cartState" });
} |
Beta Was this translation helpful? Give feedback.
I guess you literally just do
devtools(state)
anywhere and it initializes/works.