-
-
Notifications
You must be signed in to change notification settings - Fork 617
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
Problems with React Fast Refresh #1025
Comments
Hi, can you reproduce some of concrete examples in codesandbox? |
Yes, I'll look into it, when there's a reproduction 👍🏼 |
Yes, I'll try. |
@Thisen Hi, this seems related. Shouldn't the state be preserved when updating the read function?
|
@Thisen friendly ping |
After I looked at it, I'd expect your scenarios to break, given the somewhat simple implementation of our React refresh integration. The question is if we are willing to solve it. If so, we need to either re-implement the solution or find some smart way to clean up the |
Hi @Thisen, good to hear that you found it. Since atoms are functions with business logic, it would be very bad DX if React refresh is not fully supported. For my use case, it's already a mess because I need to reload my page for every change in an atom. |
@Thisen Would it be possible to use Function.toString() and see if the code is changed? @StarpTech This is a very difficult problem, but I understand it'd be nice to fix. If you have suggestions/ideas, you are very welcome. In essence, we need to learn how React deals with it and follow what it does. |
I'll try to look into it as well. It's definitely not just nice :) It doesn't fall back to hot module reload. The application will no longer work because the components aren't rerendered when a dependent atom is changed. |
@dai-shi how do you handle that in your workflow? |
Hi @StarpTech, could you try out the build in #1030? |
@Thisen Unfortunately, it doesn't help. After changing a string in an atom function used in a parent and children relationship, the parent no longer receives updates. |
👇
I don't know if it works your case, though. |
@dai-shi I tried but without success. |
Hmm, I need to look into it. Would you be able to share a codesandbox repro? |
@dai-shi I shared two. Are they sufficient to start the work? I can try to provide another one. |
Yeah, if you have split |
Is there more we can do here @dai-shi? |
@Thisen I'm still curious why this doesn't work. Would you investigate it please? const postIdAtom = atom(INITIAL_POST_ID);
export const postId = atom(
(get) => {
// update the number, will reset "postIdAtom"
console.log(3);
return get(postIdAtom);
},
(get, set, update) => set(postIdAtom, update(get(postIdAtom)))
); Even without #1030, I expect |
It should 🤔 I'll look into it! |
@dai-shi, I couldn't reproduce it - It should work with |
@Thisen #1025 (comment) should be the reproduction, as far as I recall. |
@dai-shi #1025 (comment) I don't think we can support this scenario tbh. Then we need to redo the caching mechanism for the Babel plugin. |
Hm, there must be some misunderstanding of mine. const postIdAtom = atom(INITIAL_POST_ID);
export const postId = atom(
(get) => {
// update the number, will reset "postIdAtom"
console.log(3);
return get(postIdAtom);
},
(get, set, update) => set(postIdAtom, update(get(postIdAtom)))
); What am I missing? Is it nextjs specific? |
I still don't have a reproduction with our babel plugin. |
@StarpTech do you have a reproduction? If not, I will close the issue. |
@dai-shi @alan-nf Hey, I've been reading through quickly. This issue is a bit concerning right? I'll try to check if I can find a workaround, but don't count on it :p I feel like it would be important to mention the status of this in the docs.
I'm interested in knowing if that can become an issue in the long run. Pretty sure some others are too. What you guys think? |
@TwistedMinda I'm actually still completely stumped by #1150 so I'm in favor of calling this out as a DX issue. The other big bullet item I would add is:
|
@alan-nf Yeah, alright, our best Fast Refresh wizards shall come once we raise the help flag.
Means that determining the reason why it was included in "hot-update bundles" might be difficult? (eg. in Vite) |
Sorry for ambiguous issue status. Let's close this as stale. #1203 seems a good suggestion. Let's continue. |
Hi, while it works well in most cases, we experience some bugs.
All issues happen when using react fast refresh with https://github.com/gsoft-inc/craco. We use the jotai babel preset as documented on the website!
Thank you and keep up the good work!
The text was updated successfully, but these errors were encountered: