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;
That is my code I write the style object properly, but react still arguing. Why this happens It says :
'For example, style={{marginRight: spacing + 'em'}} when using JSX.'.
My code looks like the one above, but react argues.
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>
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With