Reputation: 3077
I understand that the React way of specifying styles is
<div style={{width:"100%"}}></div>
When I specify
<div style='width:"100%'></div>
I get an error.
Is there any way of asking React to ignore the style attribute and use it as it is - a string?
What I want is for React to treat the style attribute as a string. So I want to specify the style like any other data- attribute.
Thanks
Upvotes: 1
Views: 738
Reputation: 886
According to React documentation (https://reactjs.org/docs/dom-elements.html#style):
The style attribute accepts a JavaScript object with camelCased properties rather than a CSS string.
There's no native way of doing that in ReactJS.
Upvotes: 0
Reputation: 21
If you wanted that styling to apply in certain conditions, then you could use a conditional statement inside curly brackets. But either way, React won't recognize that styling unless it's inside curly brackets
Upvotes: 2