mangocaptain1
mangocaptain1

Reputation: 555

Why use spread operator in Redux store?

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

Answers (1)

markerikson
markerikson

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

Related Questions