Tobias Tobias - 4 months ago 18
CSS Question

Multiple properties in ReactJS inlined styles object?

How do I write something that is equivalent to

CSS

.class {
display: flex;
display: -webkit-flex;
}


but using inline styles in React?

I'm basically looking for something like:

JavaScript

let styles = {
display: ['flex', '-webkit-flex']
}

Answer

Your problem is a reactJS common problem still opened and waiting for a proper solution

For webkit style, one solution is to concat values:

let styles = {
  display: 'flex; display:-webkit-flex'
}

Otherwise, a more common solution is to create a CSS named 'flex' that will be given to the className property of your element.

Third solution: use Radium. I believe it too big & tedious for your problem but you can try it if you have time... :)

Comments