score:5

Accepted answer

Try removing "" from the style props. https://codesandbox.io/s/6j91o6z56w

import React, { Component } from 'react';

class App extends Component {
  render() {
  const name = 'Red Header';
  const styleRed = {backgroundColor : 'red'};
  return (
    <div style={styleRed}>
      {name}
    </div>
  );
 }
}

score:2

Let's try with hope this helpful for u.

import React, { Component } from 'react';


class App extends Component {
  render() {
  const name = 'Red Header';
  const styleRed = {backgroundColor : 'red'};
  return (
    <div style={styleRed}>
      {name}
    </div>
  );
 }
}

export default App;

or 

import React, { Component } from 'react';

class App extends Component {
  render() {
  const name = 'Red Header';

  return (
    <div style={{backgroundColor : 'red'}}>
      {name}
    </div>
  );
 }
}

export default App;

Related Query

More Query from same tag