Using [email protected]
When I call a component that uses <style jsx> I get this written to the console (server & client)
Warning: Unknown prop `jsx` on <style> tag. Remove this prop from the element. For details, see https://fb.me/react-unknown-prop
in style (created by Unknown)
in nav (created by Unknown)
in Unknown (created by Unknown)
in div (created by Unknown)
in Unknown (created by App)
in App
The strange thing is that the problem wasn't happened on a previous run. What I did was try out next@beta then noticed that <style jsx> wasn't working there at all. I then downgrade to stable and this problem started.
Re-opening this as https://github.com/zeit/styled-jsx/issues/51
This shouldn't be happening actually, that means the transformation is not being run at all
Well the styles on [email protected] do get applied (i.e., background-color: red works) and I do get this error (not sure if this is something different than transformation). On next@beta I don't recall seeing the error and the style didn't apply at all (i.e., background-color: red doesn't work) .
@rauchg @babakness maybe I'm wrong but I think [email protected] ships with glamor and not styled-jsx. The styles are being applied because react is rendering the style tag into the html, that inject the styles (global) into the document.
@impronunciable Oh, so why doesn't it work when using next@beta?
@babakness it's working for me https://pea-qsjykozetl.now.sh/ (the code is at https://pea-qsjykozetl.now.sh/_src).
Try removing the node_modules folder and installing again to see if the issue is an outdated dependency.
That's a beautiful example @impronunciable. Thank you <3
I still get this error.
Using master branch and the example code.
I don't get the error using
"next": "^2.0.0-beta.1"
Even I am seeing this warning, I have installed next (v1.2.3) from npm though.
This seems to occur when I have two components in the same file (each with <style jsx>). Only the 1st innermost style block gets transformed. Known limitation?
No, can you provide an example please?
Dug a bit and it seems the problem happens when you have a tree of 3 components where only the root and leaf components have a <style jsx> tag, but not the middle one.
E.g. This works fine:
function C() {
return (
<div className="c">
C
<style jsx>{`
.c {
color: blue;
}
`}</style>
</div>
);
}
function B() {
return (
<div className="b">
B
<C/>
<style jsx>{`
.b {
color: green;
}
`}</style>
</div>
);
}
export default function A() {
return (
<div className="a">
A
<B/>
<style jsx>{`
.a {
color: red;
}
`}</style>
</div>
);
}
But the <style> tag from component A no longer gets transformed (along with "Unknown prop jsx on
package versions:
"styled-jsx": "^1.0.10",
Was having the same issue trying to get some Next.js boilerplate set up, what fixed it for me was installing styled-jsx (npm i styled-jsx) and adding "styled-jsx/babel" to my babel plugins.
Order matters when using in tandem with transform-react-jsx. Declare styled-jsx/babel first:
"plugins": [
"styled-jsx/babel",
"transform-object-rest-spread",
"transform-react-jsx"
]
Most helpful comment
Still present on 2.1.1