Rajesh
Rajesh Kumar's Blog

Rajesh Kumar's Blog

`style` prop expects a mapping from style properties to values

`style` prop expects a mapping from style properties to values

Rajesh's photo
Rajesh
·Nov 5, 2020·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Error:

Uncaught Error: The style prop expects a mapping from style properties to values, not a string. For example,

 style={{marginRight: spacing + 'em'}} when using JSX.

solution:

  • Check for className by mistake we add styles instead of className that's the main reason for the error try to change it and refresh the page.

  • Use "styles" prop instead of style

<span className="myClass" style={{float : 'left', paddingRight : '5px'}} > </span>
  • using className="your-class-name"
  • using style={css_object} or style={{color: this.props.color}}

Thanks.

 
Share this