Reputation: 555
In this tutorial, why is there a spread operator before createStore
?
const configureStore = () => {
const sagaMiddleware = createSagaMiddleware();
return {
...createStore(rootReducer,
applyMiddleware(sagaMiddleware)),
runSaga: sagaMiddleware.run(rootSaga)
};
};
Upvotes: 3
Views: 157
Reputation: 67479
It appears that that example is trying to add an additional field to the store object, so that you can call store.runSaga()
. To be honest, the spread/copy is totally unnecessary - you can just do store.runSaga = sagaMiddleware.run
.
Upvotes: 2