In the state like, directly with the value of the parameter of the props,
such as
state={
longitude:this.props.formData.longitude,
latitude:this.props.formData.latitude
}
But being given that formData not defined, clearly he has introduced to, and later found out the reason, because I also used two
class A extends React.Component{
constructor(){
xxxxxxxx
}
state={
longitude:this.props.formData.longitude,
latitude:this.props.formData.latitude
}
}
I thought it was not written in the constructor of the state, but it still went into error
after careful examination revealed
constructor(props){
super(props)
}
If a constructor, then the two will write, receives props, and super, otherwise props are not receiving
Reproduced in: https: //www.jianshu.com/p/f0bbbe01107c