Replies: 9 comments 2 replies
-
Thanks for reporting! Do you have multiple versions of Jotai Could you try this build in your project and see if it fixes it? Here is the link - https://ci.codesandbox.io/status/jotaijs/jotai-devtools/pr/190/builds/620643 (See |
Beta Was this translation helpful? Give feedback.
-
Seems to be all the same jotai version:
Still doesn't work with that new version either (and I would expect that if this were the issue, it also wouldn't start working just by removing the |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking a look! It does not seem to be a case of dual module hazard 🤔. I'm not able to reproduce it using the latest versions (here is a working stackblitz with your examples). Do you want to fork it and create a repro? |
Beta Was this translation helpful? Give feedback.
-
I've tried and been unable to repro on stackblitz. I thought it might be weirdness with react-compiler or StrictMode but neither of those seem to cause issues there. Weirder still, I've seen it work in my own app now, although once I restarted my webpack server it was no longer working, even though none of the code had changed. I'll dig a bit more and try to figure out what's going on. |
Beta Was this translation helpful? Give feedback.
-
Ah I see the issue, I didn't realize this library was overriding I changed my It might be nice if we could create the composed devtools store ourselves (or control the timing of it), maybe similarly to how redux-devtools works. For the time being you might want to document this behavior. It's particularly painful given that the advice is to only import the devtools in development mode, so conditional/lazy imports are probably common. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the deep dive. We're soon going to open up the gates for usage in production, too. I'm still having a hard time reproducing this with my current structure. Could you create a small repro? I'm curious to see how your app is set up. 🤔 |
Beta Was this translation helpful? Give feedback.
-
Sure, here's a minimal repro: https://stackblitz.com/edit/vitejs-vite-gychvq98?file=src%2FApp.tsx |
Beta Was this translation helpful? Give feedback.
-
Also a bit more about why this is kind of a pain to work around:
if (NODE_ENV !== 'production') {
require('jotai-devtools')
} then webpack will give me the CJS version. If I later import the devtools to render them, e.g.
then I will get the ESM version. The CJS version has all of its own infrastructure, components, functions, variables, etc., so even though it has wrapped my store, that wrapping does not work with the ESM component; the ESM component will not see my atoms.
|
Beta Was this translation helpful? Give feedback.
-
I was running into this issue too (was using a custom store and no atoms were showing in the devtools) and changing my + import { memoize } from "lodash-es";
- export const store = createStore();
+ export const getStore = memoize(createStore);
@arjunvegda What do you think about exporting jotai-devtools/src/utils/internals/compose-with-devtools.ts Lines 231 to 244 in 5a44e7f Then @tec27 could do something like this: import { memoize } from "lodash-es";
- export const getStore = memoize(createStore);
+ export const getStore = memoize(() => {
+ const store = createStore();
+ if (process.env.NODE_ENV === "development") {
+ return composeWithDevTools(store);
+ }
+ return store;
+ });
}); Happy to help out with a PR if this direction sounds promising. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I've tried various combinations to make this work with jotai's
Provider
, but nothing seems to work.I've tried:
In all cases, the DevTools never sees any atoms. I always see "No Atoms found!". If I remove the Provider, they all show up (but this is unworkable for my application).
It doesn't look like there is a test for the Provider case, only the non-Provider one, so maybe this functionality is just broken currently?
Beta Was this translation helpful? Give feedback.
All reactions