(this) Is Recognised On React Js Callback
class App extends Component { constructor(props){ super(props); this.state = { histories: [ { 'name': 'Test1
Solution 1:
You should pass arrow function as success callback for AJAX call inside onFormSubmit
method to make sure that this
inside this callback points to the component:
onFormSubmit(id) {
console.log("Started");
fetch("http://localhost:xxxx/api/Surveys/" + id + "/submit", {
method:'POST'
})
.then((response) => {
...
})
}
Post a Comment for "(this) Is Recognised On React Js Callback"