Reputation: 45
I am new in reactjs and I want to write inline if that work when I have 1 column make it center
const [boxViewWidth, setBoxViewWidth] = useState(0)
<div
style={{
...style,
columnCountBox: 1 ? right : (boxViewWidth / columnCountBox) * (columnIndex % columnCountBox) ,'calc (50% - 150px / 2)'
}}
>
Upvotes: 1
Views: 4553
Reputation: 860
To make inline statement, quick is
var a=1; var b=2;
<div style={{column: a === b ? "if true style" : "else style"}}></div>
<div style={a === b ? {column: "if true style"} : {column: "if false style"}}></div>
or with only one statement:
<div style={{column: a === b && "value if true"}}></div>
Upvotes: 1