react-redux-universal-hot-example
react-redux-universal-hot-example copied to clipboard
Require style in render() or at top of document.
Hi guys, I'm wondering if anyone can help me with a question about the (s)css-loader used? The const styles = require('./xxx.scss');
is always inside the render(). And I'm wondering why.
Because the classnames generated don't change when calling the module multiple times.
What are the advantages or disadvantage of putting the require at the top of the document instead of in the render function.
In fact, you can put const styles = require('./xxx.scss');
after import xxx from 'xx'
lines.
I think the only advantage of using require
in render()
is: just convenient.
By the way, any difference between import styles from './xxx.css'
and const styles = require('./xxx.css')
?
I'm pretty sure there was a reason regarding webpack-isomorphic-tools
. Either something related to writing the webpack-assets.json or the hot reloading.
Curious about this too. Trying to figure out if this is a convention I should be using in other projects. @erikras looks like you first did this? https://github.com/erikras/react-redux-universal-hot-example/commit/3f12085bf832a5b0d1b6f6be1d12c8ef262ed786#diff-ce1c05c91099707f867faa02837d5756R40