下载Redux调试插件
import { createStore, applyMiddleware,compose } from "redux";
import thunk from "redux-thunk";
import rootReducer from "./reducers/index";
const initialState = {};
const middleware = [thunk]
const store = createStore(
rootReducer,
initialState,
compose(
applyMiddleware(...middleware),
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
)
) //数组,对象,方法
export default store
- 下载插件
- 引入compose
- 将所需要文件放置到compose
@20181122 补充
在React+TypeScript项目实践中发现redux Dev tool 对ts项目支持性能并不是很好
具体解决方案
hello all, just in case this is useful to others, i personally found this middleware-less code readable enough:
const store = createStore(
rootReducer,
initialState,
(window as any).__REDUX_DEVTOOLS_EXTENSION__ &&
(window as any).__REDUX_DEVTOOLS_EXTENSION__()
);
note that you many need to set no-any
to false in your tslint.json file
会对某些东西不支持,具体请访问
https://github.com/zalmoxisus/redux-devtools-extension/issues/134#issuecomment-379861240
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭