Skip to content

Commit d289a2b

Browse files
committed
change cond
1 parent 14c524c commit d289a2b

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

packages/next/shared/lib/flush-effects.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export const FlushEffectsContext = createContext<FlushEffectsHook | null>(
88

99
export function useFlushEffects(callbacks: () => React.ReactNode): void {
1010
const flushEffectsImpl = useContext(FlushEffectsContext)
11-
if (!flushEffectsImpl) {
12-
throw new Error(`useFlushEffects can not be called on the client.`)
13-
}
11+
// Should have no effects on client where there's no flush effects provider
12+
if (!flushEffectsImpl) return
1413
return flushEffectsImpl(callbacks)
1514
}

test/e2e/app-dir/rsc-basic/app/root-style-registry.client.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ export default function RootStyleRegistry({ children }) {
3030
)
3131
})
3232

33-
if (typeof window !== 'undefined') {
34-
return children
33+
// Only include style registry on server side for SSR
34+
if (typeof window === 'undefined') {
35+
return (
36+
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
37+
<StyleRegistry registry={jsxStyleRegistry}>{children}</StyleRegistry>
38+
</StyleSheetManager>
39+
)
3540
}
36-
console.log('render')
37-
return (
38-
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
39-
<StyleRegistry registry={jsxStyleRegistry}>{children}</StyleRegistry>
40-
</StyleSheetManager>
41-
)
41+
42+
return children
4243
}

0 commit comments

Comments
 (0)