Skip to content

Commit

Permalink
Fix render loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinClowers committed Nov 22, 2022
1 parent bda2267 commit c5545c7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 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,8 @@ 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
}, []);

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

0 comments on commit c5545c7

Please sign in to comment.