Created
August 6, 2019 12:36
-
-
Save BretCameron/4a184d64ae15064d36d0cc96075a9664 to your computer and use it in GitHub Desktop.
Add redux-thunk middleware to your Redux store
This file contains hidden or 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, compose } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import rootReducer from './reducers'; | |
const initialState = {}; | |
const middleware = [thunk]; | |
let store; | |
if (window.navigator.userAgent.includes('Chrome')) { | |
store = createStore(rootReducer, initialState, compose( | |
applyMiddleware(...middleware), | |
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__() | |
)); | |
} else { | |
store = createStore(rootReducer, initialState, compose( | |
applyMiddleware(...middleware) | |
)); | |
} | |
export default store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment