styled-jsx: I got _JSXStyle is not defined with 3.4.0
👋 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?
What is the current behavior?
when I use <style jsx> in MyComponent I got _JSXStyle is not defined
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 4.42.0
- mac
What is the expected behavior?
Environment (include versions)
- OS:
- Browser:
- styled-jsx (version): 3.4.0
Did this work in previous versions?
yes
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 19
- Comments: 20 (4 by maintainers)
Commits related to this issue
- Downgrade styled-jsx (https://github.com/vercel/styled-jsx/issues/695) Upgrade some other build deps — committed to jacobmischka/ics-merger by jacobmischka 3 years ago
- Fix styled jsx https://github.com/vercel/styled-jsx/issues/695 — committed to cheddarup/react-rte by kjanoudi 3 years ago
- fix styled-jsx version see https://github.com/vercel/styled-jsx/issues/695 — committed to xeajs/electron by yejiang1015 3 years ago
- app: work around _JSXStyle is not defined see also https://github.com/vercel/styled-jsx/issues/695 — committed to fiedka/fiedka by orangecms 3 years ago
- app: work around _JSXStyle is not defined see also https://github.com/vercel/styled-jsx/issues/695 — committed to fiedka/fiedka by orangecms 3 years ago
- app: work around _JSXStyle is not defined see also https://github.com/vercel/styled-jsx/issues/695 — committed to fiedka/fiedka by orangecms 3 years ago
Hey guys, I ran into a similar issue and just found a workaround for my use case. Hopefully it can shed a light on yours?
TL;DR
More context
I was actually trying to import a component from a local package (yarn workspaces + lerna setup) that had
<style jsx>blocks andstyled-jsx@3.4.4as external dependency.Next app (website)
package.jsonNext app (component lib)
package.jsonAdding the snippet below inside the component library app
index.jsfile did the trick. The_JSXStyleis now being correctly imported/compiled bywebpack.Adding the above directly inside the Next app (website) and installing
styled-jsx@3.4.4as a dependency did also fix the problem whilst troubleshooting.Inspired on this article
I got error
_JSXStyle is not definedwhen my components use destructuring;import _JSXStyle2 from "styled-jsx/style";but it should beimport _JSXStyle from "styled-jsx/style";@Timer I noticed that versions prior to
3.3.3are not compatible with React 17+, although the current issue can be avoided. Can we temporarily release a tag version ofdev / alpha / betato roll back the issue so that some users can usestyled-jsxproperly first?This does not affect current users, it is just for those who want to avoid this issue, perhaps you have other solutions and would like to hear your ideas.