我正在开发 React Native 应用程序,但由于某些原因,我的 redux devtools 无法检测到商店。
这是 store.js 的代码
import { createStore, applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import jobs from './reducers/jobs';
import { watcherSaga } from './sagas';
// Saga Middleware
const sagaMiddleware = createSagaMiddleware();
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
let store = createStore(jobs, composeEnhancer(applyMiddleware(sagaMiddleware)));
sagaMiddleware.run(watcherSaga);
// Enable Hot Module for the reducers
/* eslint-disable global-require */
if (module.hot) {
// module.hot.accept('./reducers/index', () => {
// store.replaceReducers(require('./reducers').default);
// });
}
export default store;
当我打开 chrome debugger-ui 时,我在 redux 选项卡中收到“未找到商店”。
我已经从扩展设置中授予了对文件 url 的访问权限。我不知道会出现什么问题。我尝试了在教程中找到的中间件和 redux-tools 的几种商店设置,但它们似乎都不起作用。我也尝试了独立应用程序,但它没有检测到任何内容,也没有检测到 react 代码。 我做错了什么?
最佳答案
我找到了解决方案并分享它,这样可以帮助其他人。 主要问题是我使用的是 expo,因此 expo 运行在与普通开发工具不同的端口上。 我没有使用 chrome,而是下载了独立的调试器,然后,感谢这个 article ,我使用正确的端口打开了调试器,这发挥了神奇的作用:
rndebugger://set-debugger-loc?host=localhost&port=19001
关于reactjs - Redux 开发工具和 React Native,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55020120/