How to merge `css` styles with `cloneElement`?
See original GitHub issueGiven an element with css
styles, I’d like to clone it and add more css
styles.
Using a custom cloneElement
throws an error:
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it’s defined in, or you might have mixed up default and named imports.
…and using React.cloneElement
doesn’t merge the styles.
Any ideas?
cc @Andarist
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
reactjs - How can I add styles to all the children of an element
Then return a clone of each child with an appropriate style like so using React.cloneElement . This will shallowly merge any property ...
Read more >Using the React.cloneElement() function to clone elements
In this in-depth tutorial, learn how to clone and manipulate elements three different ways using the React.cloneElement function.
Read more >How to use React.cloneElement() function? - GeeksforGeeks
The first argument is the element that we want to clone. The second argument will be additional props that we want to add...
Read more >Example of React.cloneElement - CodePen
About CSS Base. It's a common practice to apply CSS to a page that styles elements such that they are consistent across all...
Read more >The css Prop - Emotion
babelrc your styles will not be applied. The plugin is not compatible with the css prop. When using React.cloneElement you can't easily add...
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
Yes, arrays will be always supported and its a good composition mechanism 😃
Yep, thanks @Andarist for your help!