1
1
12332112019-01-22 21:02:44
JavaScript
1233211, 2019-01-22 21:02:44

How to display styles depending on a variable?

There is a div with inline styles, you need to display these styles or not, depending on the variable. Is it possible to do this? I say right away that styles are needed, classes do not fit here.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly Kirenkov, 2019-01-22
@1233211

<div style={true ? { backgroundColor: 'red' } : {}}>

It's just an object.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question