React Starter Kit - passing in style object instead of class name

846 views Asked by At

With React Starter Kit's Isomorphic CSS style loader for Webpack how'd I pass in the style object instead of the class name?

We can currently do this:

<div className={s.root}>...</div>

and I wonder if we can do something like this:

<FooBar style={s.root.toObject} />

I'm looking for a solution that also works when server-side rendered.

1

There are 1 answers

2
Konstantin Tarkus On BEST ANSWER

I assume, you want to convert a piece of CSS into inline style object? E.g. .comp { border: 1px solid red; } would become { comp: { borderWidth: 1px, borderStyle: 'solid', borderColor: 'red' }. For this task you may want to search for another NPM package (both css-loader and isomorphic-style-loader are intended to solve a different problem). Try Radium.