Open semajtwin opened 1 year ago
I don't think this library is very maintained, and it doesn't work great with Next.
I'm finding it's forcing me into CSR rendering, which may be related to this
@semajtwin did you ever end up figuring out a solution to this?
Hi @NRoos, unfortunately not yet :/
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?