Skip to content

Commit

Permalink
fix: allow excessive hydration to fix hanging isReconnecting state
Browse files Browse the repository at this point in the history
As far as I've understood, the `const active = useRef(true)` was there to really make sure the effect is run just once as React doesn't guarantee that an effect won't be re-run once again, and for the same reason the dependencies were empty to minimize the redundant effect calls.

However, I think the effect still has to be run as during hot-reload component might get remounted with all connectors hanging in `isReconnecting: true` state.

Using this as a workaround for now.

Might fix wevm#3490, yet also prune to excessive re-connects that might cause UI regressions, idk.
  • Loading branch information
dalechyn authored Jan 21, 2024
1 parent ace8acf commit 76830fc
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions packages/react/src/hydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ export function Hydrate(parameters: React.PropsWithChildren<HydrateProps>) {
if (!config._internal.ssr) onMount()

// Hydrate for SSR
const active = useRef(true)
// biome-ignore lint/nursery/useExhaustiveDependencies:
useEffect(() => {
if (!active.current) return
if (!config._internal.ssr) return
onMount()
return () => {
active.current = false
}
}, [])
}, [onMount])

return children as ReactElement
}

0 comments on commit 76830fc

Please sign in to comment.