Can't pass array to css prop
See original GitHub issueHi. I’m having trouble passing an array to css prop. This is the webpack message: “Module not found: Error: Can’t resolve ‘@emotion/css’ in …”
Can someone try to reproduce it? Is this a bug? Here’s a sample:
import React from 'react'
import ReactDOM from 'react-dom'
import {css} from '@emotion/core'
function Test() {
var c1 = css`color: hotpink;`
var c2 = css`background-color: lightgray;`
var c3 = [c1, c2]
return <div css={c3}>OLA</div> // this works fine
// return <div css={[c1, c2]}>OLA</div> // this one doesn't work
}
ReactDOM.render(
<Test/>,
document.getElementById('root')
)
Thanks
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Can not pass array with objects as prop in react - Stack Overflow
The problem I experience is that questions from state can not get the passed as prop. I keep getting empty array for questions...
Read more >Pass an Array as Props - React - Free Code Camp - YouTube
In this React tutorial we pass an array as props. This video constitutes one part of many where I ... Your browser can't...
Read more >Passing Arrays as Function Arguments | SamanthaMing.com
If you want to pass an array into a variadic function. You can use ES6 spread to turn that array into a list...
Read more >Displaying Data with Props - From JavaScript to React - Next.js
If you run this code, React will give us a warning about a missing key prop. This is because React needs something to...
Read more >Spread syntax (...) - JavaScript - MDN Web Docs - Mozilla
syntax allows an iterable, such as an array or string, ... In an object literal, the spread syntax enumerates the properties of an...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I see the problem. I have a piece of bad news and a piece of good news - the bad news is that we are unable to fix it, the good news is that we have already fixed it in https://github.com/emotion-js/emotion/pull/1600 😉 The fix is going to only hit upcoming v11 though, we can’t easily backport it to v10.
v11 is very much usable (this change has not been released yet, but if you like - I can do it) and changes since v10 are minor (and we don’t plan to introduce major breaking changes anyway) but depending on the size of your project upgrade might take from 0 to some time (before final release we plan to prepare codemods which will help to migrate automatically, but they are not ready yet).
A workaround for v10 would be to do this:
Closing because there is not much we can do about this in v10 as described above. I hope you understand.