easy-peasy icon indicating copy to clipboard operation
easy-peasy copied to clipboard

easy-peasy no longer working properly with Fast Refresh

Open jmyrland opened this issue 2 years ago • 18 comments

Fast refresh is not working properly with easy-peasy. I've reproduced the issue in this codesandbox:

chrome_NVK65pZfLX

I'm not sure what caused this, as it has been working properly previously.

Current versions:

One workaround, is to use a // @refresh reset comment - but this is quite tedious.

Maybe related to this issue as well: https://github.com/ctrlplusb/easy-peasy/issues/477

jmyrland avatar Feb 07 '22 14:02 jmyrland

Thanks for the report. I'm utilising Easy Peasy again, also across React Native which might interest some. :)

I'm gonna take a look at this DX again.

ctrlplusb avatar Feb 08 '22 15:02 ctrlplusb

Definitely some strangeness going on. I can't see what or why, but there is some possibly related discussion with this issue.

ctrlplusb avatar Feb 09 '22 07:02 ctrlplusb

Definitely some strangeness going on. I can't see what or why, but there is some possibly related discussion with this issue.

Absolutely. It used to work fine before (with CRA), but at some point it stopped working. I'm not exactly sure when or what caused this.

I'll try to go through our git history to pinpoint when it stopped working. We continually update dependencies, so an unrelated dependency update might be the culprit.

Let me know if there is anything I can do to help out the debugging process 👍

jmyrland avatar Feb 09 '22 08:02 jmyrland

I've been experiencing this same issue as well.

@ctrlplusb @jmyrland fwiw, I tried using the provided codesandbox above and bumping the versions down the to versions found in the linked CRA issue (react, react-dom, and react-scripts) and it still does not seem to work: https://codesandbox.io/s/xenodochial-darkness-ci11b5?file=/src/Counter.tsx

no-stack-dub-sack avatar Feb 17 '22 21:02 no-stack-dub-sack

I've been experiencing this same issue as well.

@ctrlplusb @jmyrland fwiw, I tried using the provided codesandbox above and bumping the versions down the to versions found in the linked CRA issue (react, react-dom, and react-scripts) and it still does not seem to work: https://codesandbox.io/s/xenodochial-darkness-ci11b5?file=/src/Counter.tsx

My guess is, that this issue is caused by some peer dependency upgrade related to these packages. I'll try (as soon as I get some spare time) to go backwards through our revisions to see when this stopped working.

jmyrland avatar Feb 22 '22 14:02 jmyrland

I've tried going back through all dependency updates (1 year back) in our repository, but the issue still persists. I know that this has not been an issue for this long, so I'm out of ideas as to what is causing this issue.

Let me know if there is anything else I can assist with, to get this issue fixed.

jmyrland avatar Feb 23 '22 13:02 jmyrland

Definitely some strangeness going on. I can't see what or why, but there is some possibly related discussion with this issue.

If I disable FAST_REFRESH, hot reloading kicks in. The side-effect of this, is that the whole page rerenders.

Ideally, I'd like to enable fash-refresh, which only updates the component with the related change.

fast-refresh is working fine with pure React components.

When a component utilizes easy-peasy, the state updates are seemingly working fine, until a change is made to the component file. After a change, all the state is "delayed/pooled up" - which indicates that actions are working properly, but the state changes are not returned by useStoreState. Once the file has been changed, the "delayed state changes" is applied - but the issue still persists until another change is made to the component file. This issue is illustrated in the GIF in the issue description.

It seems that after a fast refresh of a component, the easy-peasy state is temporarily detached from the component - until the file is changed again, as state is fed into the component again, but only once after the update.

jmyrland avatar Feb 23 '22 13:02 jmyrland

+1 to this issue, I'm seeing the issue in NextJS 12.1 with hot reload.

joshcawthorne avatar Mar 08 '22 20:03 joshcawthorne

We've migrated from CRA to vite with @vitejs/plugin-react.

The issue still persists, because the plugin is configured with react-refresh.

After editing Component.tsx, actions are working properly & modifying state - but the component is not re-rendered after the action is executed (when the state is changed).

Update: If I add // @refresh reset inside the Component.tsx - everything is working as expected. 🤔

jmyrland avatar Mar 21 '22 14:03 jmyrland

Hi, did some have any updates on problem? I also experienced it on NextJS and it took me some hours to find this issue 😄

X-Tender avatar Sep 11 '22 13:09 X-Tender

Hi, did some have any updates on problem? I also experienced it on NextJS and it took me some hours to find this issue 😄

Sorry, there is no fix for this at the moment. The only solution we've found is to use the "refresh reset" comment specified above.

jmyrland avatar Sep 12 '22 06:09 jmyrland

@jmyrland this is a more general question that I may just open a separate issue for, but do you know if the community can expect any support or active maintenance of this project moving forward? It seems as if the core maintainer has gone dark for a while and issues are beginning to pile up. I completely understand how difficult it can be to maintain an OSS project but just looking to manage some expectations here. The build I have is currently working well in most scenarios but I have some open issues here that I'd love some insight on.

Thanks.

no-stack-dub-sack avatar Sep 12 '22 20:09 no-stack-dub-sack

@jmyrland this is a more general question that I may just open a separate issue for, but do you know if the community can expect any support or active maintenance of this project moving forward? It seems as if the core maintainer has gone dark for a while and issues are beginning to pile up. I completely understand how difficult it can be to maintain an OSS project but just looking to manage some expectations here. The build I have is currently working well in most scenarios but I have some open issues here that I'd love some insight on.

Thanks.

I can't speak for @ctrlplusb and his commitment to this project.

But I've got nothing but postitive feedback in regards to his work on this project. Previously, he has gone out of his way to provide patches to previous bugs & highly requested features, and it has been the most responsive OSS experience I've had.

I find that this project is quite stable despite the recent lack of activity. We use it quite extensively in our production code and have yet to find any critical issues with easy-peasy. I've only got this issue, which is just a DX-improvement if there is a solution for it.

jmyrland avatar Sep 12 '22 21:09 jmyrland

@jmyrland That's great to hear, thanks for your reply. I saw you were labeled a contributor so figured you might have some insight. Glad to hear you're using in production code and find it reliable, however. Given that, is there any chance you can comment on #732 and whether or not you've experienced this issue and whether this is expected behavior?

no-stack-dub-sack avatar Sep 13 '22 02:09 no-stack-dub-sack

It appears to be working for me in the latest alpha, which brings support for React 18;

https://github.com/ctrlplusb/easy-peasy/issues/740#issuecomment-1248303046

Could ya'll please test.

ctrlplusb avatar Sep 15 '22 16:09 ctrlplusb

It appears to be working for me in the latest alpha, which brings support for React 18;

https://github.com/ctrlplusb/easy-peasy/issues/740#issuecomment-1248303046

Could ya'll please test.

Sweet! Will test it first thing tomorrow 👍

jmyrland avatar Sep 15 '22 17:09 jmyrland

@ctrlplusb [email protected] is working great! 🎉 Here is the updated sandbox.

The sandbox uses react-scripts, but I've also tested it with react with vite & @vitejs/plugin-react.

~1400 unit testst still passing 👍

jmyrland avatar Sep 16 '22 06:09 jmyrland

May also fix #713 & #477

jmyrland avatar Sep 16 '22 07:09 jmyrland

Fixed in v5.1.0 🎉

ctrlplusb avatar Sep 17 '22 04:09 ctrlplusb