react-devTools插件自行下载后拖拽到chrome中
redux-thunk安装:npm add redux-thunk
安装完thunk后准备使用,当引入redux-thunk提示
**
TypeError: middleware is not a function
**
index.js文件下
import { createStore, compose, applyMiddleware } from 'redux'
// 创建store 传入reducer
import reducer from './reducer'
// 引入thunk
import thunk from 'redux-thunk'
// 使用chrome redux开发者工具需要
const composeEnhancers =
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ?
window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({}) : compose
//由于 applyMiddleware(...middleware)
const enhancer = composeEnhancers(
applyMiddleware(thunk)
)
const store = createStore(
reducer,
enhancer
)
export default store
react-devTools插件成功后:F12中有Redux