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

How to use styled-jsx with webpack and React only, without Babel and Next.js? #837

Open
fushihara opened this issue Aug 4, 2023 · 1 comment

Comments

@fushihara
Copy link

I am not using Next.js and Babel.
I would like to use styled-jsx with react and webpack only, is that possible?

I checked the documentation and all it says is that the webpack section is set to the babel plugin, but I am not using babel.

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

feature

What is the current behavior?

I am using style jsx in a tsx file, but the css created is not scoped and the style is applied to elements outside of React

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

https://codesandbox.io/p/sandbox/github/fushihara/react-styled-jsx-help/tree/main
image

I have defined a red background style for the .test element in React mounted in index.ejs.
The "in react" element will have a red background, as desired,
The "out react" element also has a different color, which is unnecessary.

I would prefer to isolate the style for the .test element only in the sub.tsx file.

Environment (include versions)

  • Version of styled-jsx (or next.js if it's being used):5.1.2
  • Browser:Google chrome 115
  • OS:windows 10

Did this work in previous versions?

no.

@Andrewcpu
Copy link

I'm also seeing this issue, but I was under the impression that it should work.

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