Cannot connect remote-redux-devtools in React Native

こ雲淡風輕ζ 提交于 2020-03-05 04:07:01

问题


I cannot connect remote-redux-devtools debugger in chrome and getting this error:

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)"
}

my code is the following:

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)),
);


回答1:


I found the solution, it's need to use remotedev-server. As in document it's not recommend to use remotedev-sever golbally, but I get an error with using as dev dependency so I use globally. the instruction is:

  1. install the remotedev-server globally
  2. run remotedev --port=8000
  3. open browser and go to localhost:8000/socketcluster/ ( it's still getting error if it's not include /socketcluster/ alias.
  4. you have to add specific port number and computer's IP as following:
const composeEnhancers = composeWithDevTools({
  realtime: true,
  port: 8000,
  hostname: '192.168.1.106', //add your computer's IP
});


来源:https://stackoverflow.com/questions/59946194/cannot-connect-remote-redux-devtools-in-react-native

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!