i'm calling function child component:
removeworkout: function (workoutid) { return axios.delete('/delete', { params: { id: workoutid } } .then(function(response){ this.componentdidmount(); }); },
server deletes record :
app.delete('/delete/:id?', (req, res) => { exr.find({'_id':req.query.id}).remove().exec(); console.log("server deleting") res.send("done") });
but this.componentdidmount
doesn't work, because undefined. other functions work .
its binding issue, need bind context
using .bind(this)
or use arrow function
, arrow function
job you.
use this:
.then( (response) => { this.componentdidmount(); });
or
.then( function(response) { this.componentdidmount(); }.bind(this));
Comments
Post a Comment