I have a dropdown with lists. When a list is clicked, it is displayed in a table on the other side of the page.
Whenever a new list is created, I want to display it just as if it was clicked(as shown in the code below). However, in order to display it in the table, I need to call ListAssignmentsStoreActions.loadListAssignments(list);
.
handleClick: function() {
var list = this.props.data;
ListAssignmentsStoreActions.loadListAssignments(list);
},
//invoked after initial rendering
componentDidMount: function() {
var loadAssignmentsForList = this.props.loadAssignmentsForList;
console.log("Name " + this.props.data.name);
if(loadAssignmentsForList){
this.handleClick();
}
}
The problem is that I get:
error = Error: Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch. at invariant
I don't know how to display the list other than by calling an action.