3 ms·
Sorry for asking this here, but I'm trying wrap my head around React. With the fact that we want to isolate styles for each component, how do we go about themi
by hueking 11y ago
Sorry for asking this here, but I'm trying wrap my head around React.
With the fact that we want to isolate styles for each component, how do we go about theming the components later on?
- GiovanniFrigo 11y agoI suggest you to read this (http://stackoverflow.com/a/31638988/2304450 http://stackoverflow.com/a/31638988/2304450) very good stack overflow answer, you'll find some interesting introduction to inline styles if that's what you were looking for. A different approach could be to pass a `classScope` string props down to the components, and each component then applies it to the classes it uses (Example: return (<div className={this.props.classScope + "inner-div"}></div>); ). This way we could achieve better css selector scoping, at a cost of a slightly more verbose code when using a component.
- GiovanniFrigo 11y agoAlso, you can get way more competent answers on reddit (/r/reactjs) or on stackoverflow :)
- n0us 11y agoIf you are using something like browserify you could create a module that defines the variables you want to use for theming or something and then import that module to achieve change once/ show everywhere. You could also just not do inline styles, it isn't required.