-
Notifications
You must be signed in to change notification settings - Fork 194
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
First component loses state on first hot reload #489
Comments
This seems like it's only an issue of @Jack-Works Maybe you could help on this? I'm unfamiliar with how the TS custom transformer API works. |
Hi, I see this but I'm not available recently. I'll add this to my TODO list but I'm not able to fix it in a short time. 👀 |
Yes I can reproduce this. |
Therefore the function signature is not reported to the react-refresh runtime at the first load |
@pmmmwh So the problem is
This code is called too late. Therefore react-refresh missed the first component signature |
Hey, thanks for the debugging. I've identified a fix! |
If I modify a functional component, on the first hot reload, the first component loses its internal state. Subsequent reloads are OK. It seems to depend on the order the components are imported in, so may be related to #455. Changing the order of imports of
FunctionDefault
andFunctionNamed
changes which one is affected, but one of them always is.Steps to reproduce:
yarn start
sed -E 's/more/less/g' -i ./*.tsx
Patch
Observed result
The page updates, but the state of the first component is lost (i.e. reset to the initial state). The second component maintains its state. This only occurs on the first hot reload, subsequent modifications to the components correctly preserve state.
Expected result
Both functional components should maintain their state after the modification causes a hot reload.
The text was updated successfully, but these errors were encountered: