Skip to content

Commit

Permalink
review suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
layershifter committed Jul 31, 2023
1 parent 5e14fc2 commit 8b59d72
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/react/src/insertionFactory.ts
Expand Up @@ -7,16 +7,14 @@ export const insertionFactory: GriffelInsertionFactory = () => {
const insertionCache: Record<string, boolean> = {};

return function insert(renderer: GriffelRenderer, cssRules: CSSRulesByBucket) {
if (useInsertionEffect) {
// Even if `useInsertionEffect` is available, we can't use it in SSR as it will not be executed
if (canUseDOM()) {
// eslint-disable-next-line react-hooks/rules-of-hooks
useInsertionEffect(() => {
renderer.insertCSSRules(cssRules!);
}, [renderer, cssRules]);
// Even if `useInsertionEffect` is available, we can use it on a client only as it will not be executed in SSR
if (useInsertionEffect && canUseDOM()) {
// eslint-disable-next-line react-hooks/rules-of-hooks
useInsertionEffect(() => {
renderer.insertCSSRules(cssRules!);
}, [renderer, cssRules]);

return;
}
return;
}

if (insertionCache[renderer.id] === undefined) {
Expand Down

0 comments on commit 8b59d72

Please sign in to comment.