I'm using React. I've just started recently and have some kind of knowledge gap in syntax of javascript. I don't know how to write correctly code in order to toggle element condition, from display: block
to display: none
. I'm trying to use ternary operator, but I don't know how to do it.
toggleFilters = (e) => {
this.state.showOn === true ? {e.style.display ? 'block' : 'none'}
this.setState({
showOn: !this.state.showOn,
})
}
Easier way to do it, is this. This says that your e.style.display is block if your shownOn is true else your e.style.display is false.
e.style.display = this.state.showOn ? 'block' : 'none'}
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