You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on updating a Next.js SSR application from v12 to v13. Next.js v13 requires a minimum React version of 18.2.0. Upon running the application the page rendered the application twice.
From my investigation I found that rendering the application twice is happening when using PersistGate with React v18. Whilst I found the issue in a Next.js application, I managed to replicate the same issue using React with SSR as seen below:
Here are two examples which replicate the issue using plain React with SSR:
Both solved the rendering issue however the persist/REHYDRATE action is not triggered straight after persist/PERSIST action, I fear this would lead to other issues upon initialising the application.
It may be that the setup is incorrect. However, I think that the fact that using React v17 works as expected, does point to an issue when using PersistGate with React v18.
Is this a known issue with React v18? Any possible solutions for SSR applications please?
The text was updated successfully, but these errors were encountered:
I am currently working on updating a Next.js SSR application from v12 to v13. Next.js v13 requires a minimum React version of 18.2.0. Upon running the application the page rendered the application twice.
From my investigation I found that rendering the application twice is happening when using
PersistGate
with React v18. Whilst I found the issue in a Next.js application, I managed to replicate the same issue using React with SSR as seen below:Here are two examples which replicate the issue using plain React with SSR:
Both examples have the following implementation:
server/server.js: renders
App
component wrapped withreact-redux
'sProvider
src/index.js: renders
App
component wrapped withreact-redux
'sProvider
andredux-persist
'sPersistGate
Workarounds found
Two workarounds I found on this GitHub issue:
PersistGate
PersistGate
, usepersistStore(store)
Both solved the rendering issue however the
persist/REHYDRATE
action is not triggered straight afterpersist/PERSIST
action, I fear this would lead to other issues upon initialising the application.Normal Behaviour:
Delayed Rehydration:
It may be that the setup is incorrect. However, I think that the fact that using React v17 works as expected, does point to an issue when using
PersistGate
with React v18.Is this a known issue with React v18? Any possible solutions for SSR applications please?
The text was updated successfully, but these errors were encountered: