all just want to know the difference b/w the following ways to initialize the state and is there any advantage or disadvantage over using another one, or both are just syntactic sugar.
i)
constructor(props) {
super(props)
this.state = { bar: 0 }
}
render() {
return <div>Foo</div>
}
}
ii)
class Foo extends React.Component {
state = { bar: 0 }
render() {
return <div>Foo</div>
}
}
Did anyone have any idea and what method i should prefer in which situation