Sometimes, we want to fix React inline style – style prop expects a mapping from style properties to values, not a string error with JavaScript.
In this article, we’ll look at how to fix React inline style – style prop expects a mapping from style properties to values, not a string error with JavaScript.
How to fix React inline style – style prop expects a mapping from style properties to values, not a string error with JavaScript?
To fix React inline style – style prop expects a mapping from style properties to values, not a string error with JavaScript, we set the style
prop to an object with the styles.
For instance, we write
<span className="myClass" style={{ float: "left", paddingRight: "5px" }}>
foobar
</span>
to set the style
prop to an object with some style values.
Conclusion
To fix React inline style – style prop expects a mapping from style properties to values, not a string error with JavaScript, we set the style
prop to an object with the styles.