Answer the question
In order to leave comments, you need to log in
How to properly forward forward props in state?
How to correctly forward props to state?
I use class field syntax and do it like this:
state = {
text: this.props.text
};
Answer the question
In order to leave comments, you need to log in
Here I heard an opinion from one developer that this is wrong, like "this should be inside a non-static method" and needs to be initialized in the constructor. He is right?
constructor(props){
super(props)
this.state={
text: this.props.text
}
}
In general, classes are like that, there are React Hooks . There's no need to write this in principle.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question