I've got a CRA setup with @reduxjs/toolkit
and redux-saga
.
The main saga does run. However, sub-sagas that are meant to be run on takeEvery
or fork
, do not seem to run at all.
Saga:
export function* saga() {
console.log('main'); //logs
fork(function* () {
console.log('fork') //doesn't log
});
}
Store:
const sagaMiddleware = createSagaMiddleware();
const store = configureStore({
reducer: state => {
},
middleware: defaultMiddleware => defaultMiddleware().concat(sagaMiddleware)
});
sagaMiddleware.run(saga);
Repo link. (Nothing but CRA + Toolkit + redux-saga)
Pretty sure you need to yield
both of those effects for them to do anything:
export function* saga() {
console.log('main'); //runs
yield takeEvery('*', function*() {
console.log('takeEvery') //doesnt run
})
yield fork(function* () {
console.log('gen') // doesnt run
});
}
I think the yield takeEvery
might also "block" the saga from continuing on to reach the fork? Not sure on the saga semantics here.