Last active
May 3, 2016 15:34
-
-
Save iamso1/8911844c6c3d5b34e99fcb735477f028 to your computer and use it in GitHub Desktop.
解決 Actions must be plain objects. Use custom middleware for async actions 的問題
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createStore, applyMiddleware} from 'redux'; | |
import reducers from '../reducers'; | |
import thunk from 'redux-thunk'; | |
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore); | |
export default function(initialState){ | |
const store = createStoreWithMiddleware(reducers, initialState); | |
if (module.hot) { | |
// Enable Webpack hot module replacement for reducers | |
module.hot.accept('../reducers', () => { | |
const nextRootReducer = require('../reducers'); | |
store.replaceReducer(nextRootReducer); | |
}); | |
} | |
return store; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment