I am fairly new to react and I was just wondering that why do we use this.state in constructor function and only state without constructor function while initializing state.
lets say:
i have created a component with constructor, here i have to specify this.state to intialize state.
class Test {
constructor(){
super();
this.state = {
name : ""
}
}
}
and if i create a component without constructor , i can use only state to initialize state:
class Test{
state = {
name : ""
}
}