kirill-konshin / next-redux-wrapper

Redux wrapper for Next.js
MIT License
2.67k stars 266 forks source link

[BUG]: useMemo Being a rouge agent on useHybridHydrate #540

Open adenekan41 opened 1 year ago

adenekan41 commented 1 year ago

What happened ?

While attempting to utilize the wrapper store within the getServerSideProps function provided by the wrapper, an error was encountered. Specifically, this error was initially observed when transitioning from statically generated pages (SSG) to server-side rendered (SSR) pages. However, the issue was further compounded when attempting to revisit the same SSR link from the navigation bar, causing the error to appear twice consecutively.

Screenshot 2023-04-17 at 3 05 48 AM

What did i change ?

I have implemented a fundamental change in how we handle hydration updates. Although the code was already impressive, the warning message made it clear that a setState call was being triggered within the render method of the App component while a different component (PlaylistView) was being rendered. This action is prohibited in React as it results in unpredictable behavior and may cause the application to crash or malfunction.

To tackle the issue I update the check mechanism. By allowing React to complete its lifecycle, proper data handling is ensured, resulting in an overall improvement in the fluidity of the data hydration process.

How can I reproduce this error?

Reviewers Note

This entire issue is caused by an earlyuseMemo what we want to do is hydrate when you are unMounting and rehydrate when you are Mounting "easy peezy"

ernestchakhoyan commented 1 year ago

LGTM! @kirill-konshin when you will be able to merge this pr and deploy new version? It is very important and useful PR

dovranJorayev commented 10 months ago

Tried to apply fix with patch-package and it is still there

dovranJorayev commented 10 months ago

Tried to apply fix with patch-package and it is still there

Was wrong about the fix. It is do the job. I have cloned fixed fork, builded it. After patch are applied no issues are here (Also need to remove cache). Thanks a lot @adenekan41

kaminion commented 3 months ago

Tried to apply fix with patch-package and it is still there

Was wrong about the fix. It is do the job. I have cloned fixed fork, builded it. After patch are applied no issues are here (Also need to remove cache). Thanks a lot @adenekan41

How did you build? when I use yarn, that's occur typescript error. it's not solved

dovranJorayev commented 3 months ago

I didn't really remember, but i didn't do any special. I just forked, installed with same version yarn that has in forked repo, build, apply the patch and it's done. I can share the gist of generated *.patch if it will be helpfull. Generally it is all needed to place it to {project}/patches/{patch-name})

kaminion commented 3 months ago

I didn't really remember, but i didn't do any special. I just forked, installed with same version yarn that has in forked repo, build, apply the patch and it's done. I can share the gist of generated *.patch if it will be helpfull. Generally it is all needed to place it to {project}/patches/{patch-name})

thanks, I just solve the problem!, set the node version and yarn version remove the cache in the directory