Setting default state
class Hello extends Component {
constructor (props) {
super(props)
this.state = { visible: true }
}
}
Set the default state in the constructor()
.
And without constructor using Babel with proposal-class-fields.
class Hello extends Component {
state = { visible: true }
}