I am trying to set the state of my Screen to some values that I need to send to a database afterwards. These values come from a form and are the correct values. Now I have the issue that the setState function seems to get ignored...
I have tried this code:
handleSubmit = () => {
const value = this._form.getValue();
console.log(value);
this.setState({
description: value.description,
places_free: value.places_free
})
console.log(this.state);
}
the console logs for this look as followed lines of code show:
Struct {
"description": "Test description",
"phone": "09 353 90 50",
"places_free": 2,
"website": "http://www.oakgent.be/",
}
Object {
"description": "",
"latitude": 51.055979,
"longitude": 3.711001,
"name": "Oak Restaurant",
"phone": "09 353 90 50",
"places_free": null,
"website": "http://www.oakgent.be/",
}
I also tried by setting the variables myself in the setState function to see if it has to do with the struct but that gives the same result:
handleSubmit = () => {
const value = this._form.getValue();
console.log(value);
this.setState({
description: "test",
places_free: 1
})
console.log(this.state);
}
console logs:
Struct {
"description": "Test description",
"phone": "09 353 90 50",
"places_free": 2,
"website": "http://www.oakgent.be/",
}
Object {
"description": "",
"latitude": 51.055979,
"longitude": 3.711001,
"name": "Oak Restaurant",
"phone": "09 353 90 50",
"places_free": null,
"website": "http://www.oakgent.be/",
}
I am kinda stuck at this point and I was hoping someone could lend me a hand