Answer the question
In order to leave comments, you need to log in
Why is prevState undefined?
Here is my state
this.state = {
location: null,
latitude: null,
longitude: null,
carNum: {
value: null,
validPassenger: false,
validTruck: false,
},
comment: {
value: null,
valid: false,
validationRules: {
minLength: 5
}
},
coordinateTrigger: true,
locationTrigger: true,
};
updateInputState = (key, value) => {
this.setState(prevState => {
return {
[key]: {
...prevState[key],
value: value,
valid: validate(
value,
...prevState[key]
)
}
};
});
};
<Textarea
value={this.state.comment.value}
onChangeText={val =>
this.updateInputState("comment", val)
}
/>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question