if you are getting this error it means that your `css` tagged template literals were not transpiled.

Author: harwinvoidCreated Nov 25, 2020Updated Oct 9, 2023

friend. Welcome to styled-jsx and thanks for contributing!

⚠️ IMPORTANT ⚠️

If you need help or have a question about styled-jsx please ask it on Spectrum https://spectrum.chat/styled-jsx or join our Slack community at https://zeit.chat and ask it in the #next channel.

Before you open a new issue please take a look at our Frequent Asked Questions and open issues.

Remember, often time asking in chat or looking at the FAQ/issues can be faster than waiting for us to reply to a new issue*.

If you are here to report a bug or request a feature please remove this introductory section and fill out the information below!


Do you want to request a feature or report a bug?

A bug

What is the current behavior?

image

If the current behavior is a bug, please provide the steps to reproduce and possibly a minimal demo or testcase in the form of a Next.js app, CodeSandbox URL or similar

webpack

javascript
{
              test: cssRegex,
              exclude: cssModuleRegex,
              use: [{
                loader: require('styled-jsx/webpack').loader,
                options: {
                  type: 'scoped'
                }
              }],
              // Don't consider CSS imports dead code even if the
              // containing package claims to have no side effects.
              // Remove this when webpack adds a warning or an error for this.
              // See https://github.com/webpack/webpack/issues/6571
              // sideEffects: true,
            },

babel

json
  "babel": {
    "presets": [
      "react-app"
    ],
    "plugins": [
      [
        "styled-jsx/babel",
        {
           "optimizeForSpeed": true 
        }
      ]
    ]
  }

index.css

css
.main-wrap {
    background-color: skyblue;

    
}

p {
    font-size: 16px;
    color: red;
    font-weight: bold;
}

index.js

javascript
 import React, { useState } from 'react'

 import { Button } from 'antd';

 import styles from  './index.css'

 const Card = ({onClick}) => {
     const [state, setstate] = useState(0)
     return (
     <div className='main-wrap'>
         <p>
         this is  a card {state}
         </p>
         <Button type='primary' onClick={() => setstate(state + 1)}> add </Button>

         <Button type='' onClick={() => onClick(state)}> 取 </Button>
         <style jsx>{styles}</style>
    </div>
     )
 }
 
 export default Card;

What is the expected behavior?

Environment (include versions)

  • OS: Big Sur
  • Browser: chrome latest
  • styled-jsx (version): 3.3.2

Did this work in previous versions?