DEV Community

Discussion on: React Beginner Question Thread ⚛

avinash8847 profile image

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'})

dan_abramov profile image
Dan Abramov Author

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