-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(utils): cache redux extension connections to prevent duplicates #32
base: main
Are you sure you want to change the base?
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit eef4381:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I understand the problem in the first place.
Yeah, the PR is very big and can't get it at a glance.
Is it only an issue with StrictMode? And, do yo know how react-redux solves it?
This doesn't feel right, because we never received such issues in zustand, which does something similar. (Wait, zustand doesn't use hooks, so it's jotai specific. Hmmm 🤔 )
@@ -57,7 +57,8 @@ | |||
"release:minor": "yarn run release minor", | |||
"release:patch": "yarn run release patch", | |||
"storybook": "storybook dev -p 6006", | |||
"build-storybook": "storybook build" | |||
"build-storybook": "storybook build", | |||
"prepare": "husky install" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we used husky? (I avoid it in jotai
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use husky for devtools to enforce conventional commits but we don't need the See comment belowprepare
script. So we can safely omit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, may I ask why you don't need the prepare script?
As I see it, the prepare script is required when a developer is pulling a fresh copy of the repo. It will then install the githooks you got in your .husky
directory into the .git
directory when executing npm i
and the dev would not have to execute npx husky install
by themselves.
And when you don't have the prepare script, a new contributor (like me) could commit with any message and no validation.
It probably doesn't / rarely matters for you as active maintainers, but I guess it could help new contributors :)
Or, if you don't want to enforce it and it should just be an optional convention, it also makes sense to remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right! We do need the prepare
script. I was under the impression that husky auto-installs itself. It turns out they stopped doing that long ago.
Hey, @PrettyCoffee thanks a lot for your contribution! Sorry, I missed the discussion you filed on the Jotai repo. If I understand correctly, this "bug" is caused by React 18's new approach to enforce idempotency in Strict mode. It runs hooks like So making the Please see this fix: #33 I think the bigger issue you caught is that the atom values are not being updated Did you get a chance to investigate why that could be happening? |
Yess, thats actually the problem, due to the render cycles it could be executed multiple times which should not be happening. My gut feeling says it could be more beneficial to do the exact same with atoms: Having it as a middleware or something like that instead of a hook. But I am not really deep into jotai's mechanics, so there might be reasons why you wouldn't want to do that. |
Thank you for jotai and having devtools, really feels like a blessing! :)
There lies the problem: You cannot do that with redux devtools (at least I didn't find a proper way for that)
I will have a closer look on that later. But I think that this will actually introduce bugs 😕 The According documentation: I did not find a function to actually disconnect one connection from the extension. It is all or none.
Unfortunatly I didn't find the problem there. Could be that it lies within the other cleanup issues I addressed, but I am not entirely sure. If I got the time I can have a closer look at this again. 👍 |
I'm unfamiliar with the internals of Redux DevTools Extensions, so could you help us create a small repro of the issues you're referring to? I added
Found the issue, this is happening because |
I will add a small documentation to the redux tool files and submit them in a separate PR, then we can discuss that detail there 👍
What I meant there is, that when you
you will loose all connections that are existing, even tho theoretically some should be there.
Aaaah, yes, that makes sense! Thank you for fixing :) |
Added an issue in redux-devtools to see if they got a solution for the problem: |
Originated from this discussion:
pmndrs/jotai#1795 (reply in thread)
Notes:
useAtomsDevtools
to an "empty" devtools state sicne that felt more natural to me. Let me know if you still prefer theundefined
and I will change it back.