本文介绍了无法在 React Native 中连接 remote-redux-devtools的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我无法在 Chrome 中连接 remote-redux-devtools
调试器并收到此错误:
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)"
}
我的代码如下:
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)),
);
推荐答案
我找到了解决方案,需要使用remotedev-server
.与文档中一样,不建议全局使用 remotedev-sever
,但是我在用作开发依赖项时遇到错误,因此我全局使用.指令是:
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:
- 全局安装
remotedev-server
- 运行
remotedev --port=8000
- 打开浏览器并转到
localhost:8000/socketcluster/
(如果不包含/socketcluster/
别名,它仍然会出错. - 您必须添加特定的端口号和计算机的 IP,如下所示:
- install the
remotedev-server
globally - run
remotedev --port=8000
- open browser and go to
localhost:8000/socketcluster/
( it's still getting error if it's not include/socketcluster/
alias. - 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
});
更新
更简单的方法是使用 react-native-debugger,你不不需要做这些令人头疼的步骤
UPDATE
the easier way is to use react-native-debugger, you don't need to do these headache steps
这篇关于无法在 React Native 中连接 remote-redux-devtools的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!