I'm having trouble with the error
Uncaught (in promise) Error: Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.(…)
I have tried everything I found on the web.
Source:
import Firebase from 'firebase';
import StudentsActions from '../actions/StudentsActions';
import _ from 'lodash';
let firebaseRef = new Firebase('https://radiant-heat-2605.firebaseio.com/students');
let StudentsSource = {
getStudents: {
remote(state, students){
return new Promise((resolve) => {
console.log(students, 'students');
console.log(state, 'state');
resolve();
if(!students) {
}
students = _(students).keys().value();
let returnStudents = {};
students.map((student, index) => {
firebaseRef.child(student).once('value', (dataSnapshot)=> {
returnStudents[dataSnapshot.key()] = dataSnapshot.val();
}).then(() => {
//If the loop ended, resolve this promise.
if (index === students.length - 1) {
resolve(returnStudents);
}
});
});
});
},
success: StudentsActions.studentsReceived,
error: StudentsActions.studentsFailed,
loading: StudentsActions.studentsLoading
}
}
export default StudentsSource;
I started with calling the getStudents from the store directly but tried the approach via an action because that was suggested alot. But this error happens ever sinceI added the loading attribute. And I really need it. You can find the complete code on my github: https://github.com/JannesV/devinestagram
I'm having trouble with the error
Uncaught (in promise) Error: Invariant Violation: Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.(…)
I have tried everything I found on the web.
Source:
Store:
I started with calling the getStudents from the store directly but tried the approach via an action because that was suggested alot. But this error happens ever sinceI added the loading attribute. And I really need it. You can find the complete code on my github: https://github.com/JannesV/devinestagram