So for example I want to do something like this:
const style = {
color: 'red'
}
<div style={style + { width: '10%' }}>Hello</div>
To combine the style in the constant and inline in JSX.
So for example I want to do something like this:
const style = {
color: 'red'
}
<div style={style + { width: '10%' }}>Hello</div>
To combine the style in the constant and inline in JSX.
You want to use spread syntax (...) to combine objects.
const style = {
color: 'red'
};
<div
style={{
// Spread out previous `style` properties
...style,
width: "10%",
}}
>
Hello
</div>