Hi,
Not sure if this is a preference thing or not, but I see that some people use a constructor when setting state, whereas other people don’t. Examples below.
Q: Any cons of just setting state and bypassing the extra characters typing up constructor?
class App extends Component {
constructor(){
super()
this.state = {}
}
render() {
return (
<div className="App">
<h1>Test</h1>
</div>
);
}
}
export default App;
class App extends Component {
state = {}
render() {
return (
<div className="App">
<h1>Test</h1>
</div>
);
}
}
export default App;