【问题标题】:Cannot connect remote-redux-devtools in React Native无法在 React Native 中连接 remote-redux-devtools
【发布时间】:2020-05-13 17:13:17
【问题描述】:

我无法在 chrome 中连接 remote-redux-devtools 调试器并收到此错误:

SocketProtocolError {
  name: "SocketProtocolError", 
  message: "Socket hung up", 
  code: 1006, 
  stack: "SocketProtocolError: Socket hung up
         at SCSocke…e?platform=android&dev=true&minify=false:2648:44)"
}

我的代码如下:

import thunk from 'redux-thunk';
import {persistReducer, persistStore} from 'redux-persist';
import {composeWithDevTools} from 'remote-redux-devtools';
import * as actions from './actions';
import rootReducer from './reducers';
import {REMEMBER_LIST} from '../constants';

const persistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: REMEMBER_LIST,
};

const persistedReducer = persistReducer(persistConfig, rootReducer);

const composeEnhancers = composeWithDevTools({realtime: true});

const store = createStore(
  persistedReducer,
  composeEnhancers(applyMiddleware(thunk)),
);

【问题讨论】:

    标签: react-native redux


    【解决方案1】:

    我找到了解决方案,它需要使用remotedev-server。如文档中所示,不建议使用remotedev-sever golbally,但使用作为开发依赖项时出现错误,因此我在全局范围内使用。指令是:

    1. 全局安装remotedev-server
    2. 运行remotedev --port=8000
    3. 打开浏览器并转到localhost:8000/socketcluster/(如果不包含/socketcluster/别名,它仍然会出错。
    4. 您必须添加特定的端口号和计算机的 IP,如下所示:
    const composeEnhancers = composeWithDevTools({
      realtime: true,
      port: 8000,
      hostname: '192.168.1.106', //add your computer's IP
    });
    

    更新

    更简单的方法是使用react-native-debugger,你不需要做这些令人头疼的步骤

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-03
      • 2021-04-16
      • 1970-01-01
      • 2021-12-21
      • 2019-08-23
      • 1970-01-01
      • 2023-01-21
      相关资源
      最近更新 更多