Dynamically Assign Styles
1 | render() { |
Dynamically Change Classes
1 | // App.css |
1 | let classes = []; |
Use Radium to render qsuedo class
Install Radium npm install --save radium
1 | // Component.js |
Use CSS module
- With CSS modules, you can write normal CSS code and make sure, that it only applies to a given component.
- Read more here
npm run eject
- In the
config/webpack.config.js
findtest: cssRegex
Replace that section with
1
2
3
4
5
6
7test: cssRegex,
exclude: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
modules: true,
localIdentName: '[name]__[local]__[hash:base64:5]'
}),Restart server
In the App.js
1 | import classes from './App.css'; |
- To use Classes globally:
:global .Post { ... }