Replies: 1 comment
-
I cant say I fully understand the problem. A codesandbox reproduction would likely help here. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a page that we statically generate (SSG) with Next.js where we fetch a
staticProps
object (withorg
andgrants
inside) beforehand on the server-side.The page component that consumes this follows:
Using this component, sometimes we will have a rendering problem when hydrating, breaking the UI significantly because react can't properly hook everything up. After many hours debugging this, the root cause I found is actually the cache key for the
orgGrantsResult
query, more specifically theorg?.id
part of the key. I don't understand why this happens since the server will always have theorg
(and consequentiallyorg.id
) because this is SSG fetched but looking into theorgGrantsResult
when the error happens, the query status isloading
instead of success, even though thestaticProps.grants
object for sure is there.My question is if this is a race condition between react and react-query or me misunderstanding how the hydration process works? I fixed this by not using
org?.id
butein
as part of the key but this is not optimal since when new grants are created, we only have access to theorg.id
and invalidate based on that value.Any help greatly appreciated 🙏
Beta Was this translation helpful? Give feedback.
All reactions