React js css inline style margin right not working

Jer*_*ker 4 css reactjs

I want to implement margin-right inline CSS to the below react span element:

import React, { Component } from "react";   
class NavBar extends Component {
  state = {
    totalCounters: 0,
  };      
  render() {    
    let styles = {
        margin-right: '20px',
        width: '250px',
        height: '250px',
        backgroundColor: 'yellow',
      };
    return (
      <nav className="navbar navbar-light bg-light">
        <a className="navbar-brand" href="#">
          Navbar
        </a>
        <span style={styles} className="badge badge-pill badge-secondary">
          {this.props.totalCounters}
        </span>
      </nav>
    );
  }
}
export default NavBar;
Run Code Online (Sandbox Code Playgroud)

But it shows syntax error, while no error if replacing margin-right with margin. So how to do it?

lar*_*arz 5

React使用camelCase作为内联样式属性。尝试一下marginRight: '20px',就像您对backgroundColor