diff --git a/src/useStyleRegister.tsx b/src/useStyleRegister.tsx index ef385d3..d581fb9 100644 --- a/src/useStyleRegister.tsx +++ b/src/useStyleRegister.tsx @@ -179,6 +179,10 @@ function uniqueHash(path: (string | number)[], styleStr: string) { return hash(`${path.join('%')}${styleStr}`); } +function Empty() { + return null; +} + /** * Register a style to the global style sheet. */ @@ -230,12 +234,12 @@ export default function useStyleRegister( ); return (node: React.ReactElement) => { - if (isMergedClientSide || !defaultCache) { - return node; - } + let styleNode: React.ReactElement; - return ( - <> + if (isMergedClientSide || !defaultCache) { + styleNode = ; + } else { + styleNode = ( ', ); @@ -116,7 +131,11 @@ describe('SSR', () => { // Force insert style since we hack `canUseDom` to false mock="client" > - + + + + + , { hydrate: true, @@ -133,7 +152,11 @@ describe('SSR', () => { it('tricky ssr', () => { const html = renderToString( - + + + + + , ); @@ -152,7 +175,11 @@ describe('SSR', () => { // Force insert style since we hack `canUseDom` to false mock="client" > - + + + + + , { hydrate: true,