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

css prop stopped working in nextjs@11.0.0 #349

Open
Lwdthe1 opened this issue Aug 21, 2021 · 2 comments
Open

css prop stopped working in nextjs@11.0.0 #349

Lwdthe1 opened this issue Aug 21, 2021 · 2 comments

Comments

@Lwdthe1
Copy link

Lwdthe1 commented Aug 21, 2021

I have been using the css prop to style my components since nextjs@10.2.0 (also tested at @10.2.3, the latest version before 11.0.0). It's been working wonderfully.

When I upgrade nextjs to 11.0.0, the css props is no longer compiled; the template string is just rendered as is.

<div css={css`background: red`}>...</div>

// becomes
<div css="background: red">...</div>

That means no styling from the css prop is applied to the element as desired.

This is the only console error log when I refresh the page:
Screen Shot 2021-08-21 at 1 02 19 PM

But even when I resolve that error, the problem at hand remains.

Using the styled.div approach still works, though.

@Lwdthe1 Lwdthe1 changed the title css prop stopped working in nextjs@11.1.0 css prop stopped working in nextjs@11.0.0 Aug 21, 2021
@simon-debruijn
Copy link

Have you removed your babel.config.json or .babelrc? Because if you did, you moved to SWC instead of Babel.
The css prop of styled-components isn't supported yet for SWC.

Adding a config for babel will likely resolve your issue:
https://styled-components.com/docs/tooling#babel-plugin

@Lwdthe1
Copy link
Author

Lwdthe1 commented Aug 21, 2023

Thanks for those links. Looks like this may have been resolved in NextJS 12.2.0 https://github.com/vercel/next.js/releases/tag/v12.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants