Skip to content
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

fix(emotion): fix render loop #78

Merged
merged 3 commits into from
Apr 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion emotion/app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const Document = withEmotionCache(
const clientStyleData = useContext(ClientStyleContext);

// Only executed on client
// When a top level ErrorBoundary or CatchBoundary are rendered,
// the document head gets removed, so we have to create the style tags
useEffect(() => {
// re-link sheet container
emotionCache.sheet.container = document.head;
Expand All @@ -50,7 +52,9 @@ const Document = withEmotionCache(

// reset cache to re-apply global styles
clientStyleData.reset();
}, [clientStyleData, emotionCache.sheet]);
// We only want to do this on mount, not when styles change
// eslint-disable-next-line react-hooks/exhaustive-deps
MichaelDeBoey marked this conversation as resolved.
Show resolved Hide resolved
}, []);

return (
<html lang="en">
Expand Down