import {applyMiddleware,compose,createStore} from "redux"
import reducer from './reducer'
import logger from 'redux-logger'
import thunk from 'redux-thunk'
let initialState = {
visbility:'SHOW_ALL',
todos:[{
id:0,
completed: false,
text:'initial for demo'
}]
}
let finalCreateStore = compose(
applyMiddleware(thunk,logger())
)(createStore)
function configureStore(initialState){
return finalCreateStore(reducer,initialState)
}
let store = configureStore(initialState)
export default store
之後我們action.js裡面寫的方法不只可以return物件,還可以return function
let finalCreateStore = compose(
applyMiddleware(thunk,logger()),window.devToolsExtension ? window.devToolsExtension() : f => f
)(createStore)
function configureStore(initialState){
return finalCreateStore(reducer,initialState)
}
let store = configureStore(initialState)
export default store