trying to add some eleemnts to exist style properties,
how to destruct and add some elements conditionally
retun <div style={{...FULL, screenMinimized ? overflow: 'auto' : display:'none' }}>
...
const FULL: React.CSSProperties = {
flex: 1,
display: 'flex',
flexDirection: 'column',
}
>Solution :
You could use the ternary on the property value you are trying to set/override in the style prop object.
Example:
<div
style={{
...FULL,
overflow: screenMinimized ? 'auto' : 'hidden',
}}
>
...
</div>
If you want to conditionally set different properties though you’ll need to create each as a separate object to be spread into the style prop object:
<div
style={{
...FULL,
...(screenMinimized ? { overflow: 'auto' } : { display: 'none' })
}}
>
...
</div>