无法让 redux devtools 用于调试 React Chrome 扩展程序



在让Redux开发工具工作时遇到一些问题。当我打开devtools中的redux选项卡时,它会显示";找不到商店。请务必按照说明进行操作;。我试着按照1.1 Basic store下的说明进行操作,但没有成功。然后我尝试了1.3使用npm的redux devtools扩展包,但也不起作用。这是我的index.js

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import "./index.css";
import App from "./components/App";
import reportWebVitals from "./reportWebVitals";
import reducers from "./reducers";
import { createStore, applyMiddleware } from "redux";
import { composeWithDevTools } from "redux-devtools-extension";
const store = createStore(
reducers,
composeWithDevTools()
// other store enhancers if any
);
ReactDOM.render(
<React.StrictMode>
<Provider store={store}>
<App />
</Provider>
</React.StrictMode>,
document.getElementById("root")
);
reportWebVitals();

试试这个:

const initialState = {};
const middleware = [thunk];

const store = createStore(
rootReducer,
initialState,
composeWithDevTools(applyMiddleware(...middleware))
);

相关内容

  • 没有找到相关文章

最新更新