styled-jsx: _JSXStyle is not defined
my .babelrc file
"plugins": [
[
"styled-jsx/babel"
],
"inline-dotenv",
["module-resolver", {
"root": ["./src"]
}],
["@babel/plugin-proposal-decorators", { "legacy": true }],
[
"import", {
"libraryName": "antd",
"style": true
}
]
],
my js
<style jsx>{`
span {
color: red;
}
`}</style>
then i got error ~ Please give me solution for this problem.
ReferenceError: _JSXStyle is not defined
Environment (include versions)
- OS: mac windows
- Browser: chrome
- styled-jsx (version): styled-jsx 3.2.1 nextjs 8.0.1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 17
- Comments: 15 (1 by maintainers)
I also ran into this while trying to include styled-jsx-plugin-sass. Instead of directly adding plugins to the babel configuration you need to update the next/babel preset:
Found in docs here
@BradEP You’re right!
next/babel preset contains styled-jsx, so do not add duplicates to existing plugins and use the default preset.
Any suggestions on how to fix this for large projects that start using
next-jsandstyled-jsxalong time ago? I can’t afford to manually pasteimport _JSXStyle from "styled-jsx/style"in every file that usesstyled-jsxI’m still also trying to get this to work and #545 is not the issue I think (I’m not using a different version of styled-jsx now at all in my dependencies). I was getting the same _JSXStyle is not defined and while attempting to debug I tried this which actually caused it to work;
MainLayout.jsx