In the code below why is the first instance of
const classDropdownMenu = 'dropdown-menu' + (this.state.isToggleOn ?' show' : '')
this.state.isToggleOn enclosed in paretheses, but the second instance
{this.props.children}
is enclosed in curly brackets.
I am new to reactjs and I am trying to grasp when to use curly brackets vs parentesis.
Is it because the first instance is using string concatenation in jsx and the second instance is evaluating a variable inside a jsx function? So if you are inside a jsx function you need to evaluate, else jsx already knows about it?
class NavDropDown extends React.Component {
constructor(props){
super(props)
this.state = {
isToggleOn:false
}
}
render(){
const classDropdownMenu = 'dropdown-menu' + (this.state.isToggleOn ?' show' : '')
return (
<li className="nav-item dropdown-toggle" hfref="/" id="navbarDropdown" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<div className={classDropDownMenu} aria-labelledby="navbarDropdown">
{this.props.children}
</div>
</li>
)
}
}