Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix styled-components setup in turbo example #44165

Merged
merged 2 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/with-turbopack/lib/styling.tsx
Expand Up @@ -9,11 +9,12 @@ export function useStyledComponentsRegistry() {

const styledComponentsFlushEffect = () => {
const styles = styledComponentsStyleSheet.getStyleElement();
styledComponentsStyleSheet.seal();
styledComponentsStyleSheet.instance.clearTag();
return <>{styles}</>;
};

function StyledComponentsRegistry({ children }: ChildProps) {
if (typeof window !== 'undefined') return <>{children}</>;
return (
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
{children as React.ReactChild}
Expand Down
14 changes: 10 additions & 4 deletions test/e2e/app-dir/rsc-basic/app/root-style-registry.js
Expand Up @@ -29,9 +29,15 @@ export default function RootStyleRegistry({ children }) {
return <>{styledComponentsFlushEffect()}</>
})

return (
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
<StyleRegistry registry={jsxStyleRegistry}>{children}</StyleRegistry>
</StyleSheetManager>
const child = (
<StyleRegistry registry={jsxStyleRegistry}>{children}</StyleRegistry>
)
if (typeof window === 'undefined') {
return (
<StyleSheetManager sheet={styledComponentsStyleSheet.instance}>
{child}
</StyleSheetManager>
)
}
return child
}