DEV Community

Discussion on: React Beginner Question Thread ⚛

Collapse
 
avinash8847 profile image
Avinash

Hi Dan,

I'm new to react wanted to ask if react set states asynchronously, why it is a need for declaring on the first place State = { name: ''} when it is assigned automatically when we use this.setState({name:'Dan'})

Collapse
 
dan_abramov profile image
Dan Abramov

So that you set the initial value without adding any lifecycle methods.