what is the difference between createStore and cre

2019-04-09 17:55发布

问题:

I found two ways to configure redux createStore ,

1.https://github.com/TeamWithBR/SampleProjectTodo/blob/master/src/store/configureStore.js

2.https://github.com/aknorw/piHome/blob/9f01bc4807a8dfe2a75926589508285bff8b1ea6/app/configureStore.js

Which is preferable?

回答1:

createStoreWithMiddleware is the old way to create the store with enhancers in Redux. In Redux version 3.1.0, a new approach has been introduced and now createStore receives an enhancer such as applyMiddleware() as the last optional argument.

Now, the new createStore approach is preferable as it leads to code that is easier to read and reason about, but both will work.