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

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

·

1 min read

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.