Hands-on practice for this lecture. Write the code, see it run, understand the pattern.
Exercise 1 of 1
Four questions testing the store wiring: what createSagaMiddleware() returns, why middleware order matters, what an idle saga middleware does, and why saga.run() must come after createStore().
Four questions on the Redux Saga setup: what createSagaMiddleware returns, middleware ordering, what happens when the middleware is idle, and the timing rule for saga.run().
createSagaMiddleware Return Value
import createSagaMiddleware from 'redux-saga'; const saga = createSagaMiddleware();
1What is stored in the saga variable after this code runs?
Middleware Order
const store = createStore(
allReducers,
composeWithDevTools(
applyMiddleware(saga, thunk, logger)
)
);2Why must logger be last in applyMiddleware?
Idle Middleware
3The store is created with applyMiddleware(saga). No saga.run() has been called. What happens when an action is dispatched?
saga.run() Timing
const saga = createSagaMiddleware(); saga.run(rootSaga); // called here const store = createStore( allReducers, applyMiddleware(saga) );
4What happens when this code runs?
0/4 answered