Redux配置商店的createStore方法

时间:2016-09-21 12:17:58

标签: react-redux

我找到了两种方法来配置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

我尝试了,两者都可以工作

TEST1

import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { Router, browserHistory } from 'react-router';
import reduxThunk from 'redux-thunk';
import routes from './routes';
import App from './components/app';
import reducers from './reducers';


const createStoreWithMiddleware = applyMiddleware(reduxThunk)(createStore);

ReactDOM.render( 
    <Provider store={createStoreWithMiddleware(reducers)}>
      <Router history={browserHistory} routes={routes} />
    </Provider>, document.querySelector('#app'));

TEST2

const createStoreWithMiddlewareTest = createStore(reducers, applyMiddleware(reduxThunk));

ReactDOM.render(
  <Provider store={createStoreWithMiddlewareTest}>
    <Router history={browserHistory} routes={routes} />
  </Provider> , document.querySelector('#app'));

但我不知道他们之间有什么区别? 请指导我

0 个答案:

没有答案