Why use an operator spread on a Redux store?

In this tutorial , why does the spread operator before exist createStore

?

const configureStore = () => {
  const sagaMiddleware = createSagaMiddleware(); 
  return {
    ...createStore(rootReducer,
      applyMiddleware(sagaMiddleware)),
    runSaga: sagaMiddleware.run(rootSaga)
  };
};

      

+3


source to share


1 answer


It looks like this example is trying to add an extra field to the store object so that you can call store.runSaga()

. To be honest, the redistribution / copy is completely unnecessary - you can just do store.runSaga = sagaMiddleware.run

.



+2


source







All Articles