-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wip: attempt at preact hydration support #403
Conversation
@@ -691,6 +697,12 @@ export function Scripts(props: ScriptProps) { | |||
serverHandoffString | |||
} = useRemixEntryContext(); | |||
|
|||
let hydratedRef = React.useRef(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this isn't used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, this is just a POC as I'm not a fan of the global variable here on window. I just wanted to prove that we can remove script tags after hydration for subsequent re-renders. This works as we load the context in the client entry component and that one never re-mounts as our error boundary logic is lower in the tree from there around each individual route.
let hydratedRef = React.useRef(false); | ||
|
||
React.useEffect(() => { | ||
window.remixIsHydrated = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's only ever one copy of components.tsx
running on a page, so it should be possible to use a module variable here:
let isHydrated = false;
function Scripts() {
React.useEffect(() => {
isHydrated = true;
}, []);
React.useMemo(() => {
// <snip>
return (
<>
{dedupe(preloads).map(path => (
<link
key={path}
rel="modulepreload"
href={path}
crossOrigin={props.crossOrigin}
/>
))}
{initialScripts}
{isHydrated ? null : initialScripts}
</>
);
}, []);
}
ab9dac4
to
172ecc9
Compare
superseded by #422 |
No description provided.