Skip to content

Commit

Permalink
fix: fix plugin-emotion-cache style sync when using initialData
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisvxd committed Jan 10, 2025
1 parent cc3b3b8 commit ac8679c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions packages/plugin-emotion-cache/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ const createEmotionCachePlugin = (key: string): Plugin => {

// eslint-disable-next-line react-hooks/rules-of-hooks
useEffect(() => {
if (document) {
setCache(
createCache({
key,
container: document.head,
})
);
}
// Defer until next render
setTimeout(() => {
if (document) {
setCache(
createCache({
key,
container: document.head,
})
);
}
}, 0);
}, [document, key]);

if (cache) {
Expand Down

0 comments on commit ac8679c

Please sign in to comment.