The list is displaying fine. In fact everything is displaying fine. When I click delete, the popup is telling me it’s deleted the category but it isn’t removed from the collection. Here is the method to remove it:
i think the issue is due to it didn’t re-render after deletion. There are two ways that I can think of, one is using the this.setState in your deleteCat method, and the second is utilize the shouldComponetUpdate . However, the above two ways might result a race condition that you might not see the Bert.alert due to the re-rendering. the way you can solve it is by passing your item data to a child component. I hope this help
Thanks for your response! Doesn’t quite work though, getting this in console:
Warning: bind(): React component methods may only be bound to the component instance. See DashCategoryList
The second method then tells me that event.preventDefault() isn’t a function. Removing it then returns back to normal (bert alert fires, but category isn’t removed).
What’s going on here is, I’m just making a new function on the fly, taking the event object (e) and passing it to deleteCat, along with the item ID. And then we’ve got: (see comments)
// deleteCat now accepts two arguments
deleteCat: function(event, itemId) {
event.preventDefault();
// Remember that Meteor.call accepts a callback as the last parameter. I moved the Bert.alert
// call inside the callback, so that it only gets called once the method is actually completed.
Meteor.call('deleteCategory', itemId, (error, result) => {
if (!error) {
Bert.alert({title: "Category Deleted", type: 'success', icon: 'fa-check', style: 'growl-top-right'});\
}
});
},