Answer the question
In order to leave comments, you need to log in
How to copy all props into state?
When I started learning react, I saw somewhere that all properties are copied to the state, in the constructor. Maybe I'm already confusing something, but is there such an entry: this.state = {props}
?
Answer the question
In order to leave comments, you need to log in
There is one, but most likely you have seen this : this.state = {...props}
Then you won’t need to write this.state.props.foo
, you can contact through this.props.foo
.
In my opinion this is bad practice and should only be done in some very limited scenarios.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question