Skip to content

Commit eb3d700

Browse files
fix(hydration): useMemo for hydrating again
1 parent c98968c commit eb3d700

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/hydration/react.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ export function useHydrate(state: unknown, options?: HydrateOptions) {
1111

1212
// Running hydrate again with the same queries is safe,
1313
// it wont overwrite or initialize existing queries,
14-
// relying on useEffect here is only a performance optimization
15-
React.useEffect(() => {
14+
// relying on useMemo here is only a performance optimization.
15+
// hydrate can and should be run *during* render here for SSR to work properly
16+
React.useMemo(() => {
1617
if (state) {
1718
hydrate(queryClient, state, optionsRef.current)
1819
}

0 commit comments

Comments
 (0)