(This is a just quick tip not an elaborated post sorry)
Thanks to Babel Macro, we don't need to eject our CRA project.
- Use
import styled from 'styled-components/macro'
- Install
npm install babel-plugin-macros
- Create
.babelrc
in your project root - Then add this to your .babelrc
{
"plugins": ["babel-plugin-styled-components"]
}
This option enhances the attached CSS class name on each component with richer output to help identify your components in the DOM without React DevTools.
It also allows you to see the component's displayName in React DevTools.
Voilà, enjoy!
More info: https://styled-components.com/docs/tooling#babel-macro
Top comments (0)