displayName doesn't work
axhamre opened this issue · comments
What I've done
- Installed create-react-app
- Added
react-app-rewired
,react-app-rewire-styled-components
andstyled-components
- Tried both to use
react-app-rewire-styled-components
as is AND added config"displayName": true
Expected behaviour
In the browser dev tool, would like to have " nicer generated class names that include the components' name".
Result
The class names aren't changed, they have their default randomized look.
Demo
Can you post your config please? It works perfectly fine for us so it's most likely a usage issue.
Hm, weird.
The config was in the demo:
const rewireStyledComponents = require("react-app-rewire-styled-components");
/* config-overrides.js */
module.exports = function override(config, env) {
config = rewireStyledComponents(config, env, {
displayName: true
});
return config;
};
And here are two screenshots of the
- source code (styled component
Message
) - the resulting webpage
- dev tools
Oh, you need to set up react-app-rewired
properly by replacing react-scripts start
in the package.json with react-app-rewired start
, see https://github.com/timarney/react-app-rewired
Oh 😳
Thank you very much. And sorry for taking up your time!
No worries, happy to help! Next time, you'd probably get a faster answer if you ask in the styled-components community though 😉