process.nextTick不是函数(React native,ddp,meteor)

Mag*_*nna 4 meteor ddp react-native

在本机上做反应,我试图使用'ddp-client'节点库连接到流星服务器.在连接成功后,我在客户端获得以下错误:

2016-01-17 16:14:15.992 [trace][tid:com.facebook.React.JavaScript] ddp message: {"msg":"connected","session":"PGLBqgvoeuXgBtke2"}
2016-01-17 16:14:16.007 [warn][tid:com.facebook.React.JavaScript] process.nextTick is not a function. (In 'process.nextTick(function(_this){
return function(){
return _this._flush();};}(

this))', 'process.nextTick' is undefined)
2016-01-17 16:14:16.008 [error][tid:com.facebook.React.RCTExceptionsManagerQueue] Unhandled JS Exception: process.nextTick is not a function. (In 'process.nextTick(function(_this){
return function(){
return _this._flush();};}(

this))', 'process.nextTick' is undefined)
Run Code Online (Sandbox Code Playgroud)

小智 6

process.nextTick在React Native上不存在,所以我们必须对它进行polyfill.这很简单process.nextTick = setImmediate.

示例:https://github.com/spencercarli/meteor-todos-react-native/blob/master/ReactNativeTodos/app/config/db/lib/process.polyfill.js

您需要确保在根组件文件中执行此操作(例如index.ios.js)

希望这对你有所帮助!