On react native, I am trying to use 'ddp-client' node library to connect to a meteor server. Just after the connection is successful, I am getting the following ERROR on client side:
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)
process.nextTick
doesn't exist on React Native so we've got to polyfill it. That is as simple as process.nextTick = setImmediate
.
Example: https://github.com/spencercarli/meteor-todos-react-native/blob/master/ReactNativeTodos/app/config/db/lib/process.polyfill.js
You'll want to make sure you do this in your root component file (eg index.ios.js)
Hope this helps you!
I've come across the same problem, but @Spencer Carli's answer is not perfect, in debugging mode, shimming nextTick is not only unnecessary (js runs in v8 when debugging), it will also make your app failed to connect the development server (I don't know why, but it actually does). So the more suitable answer is:
if (!__DEV__) {
global.process.nextTick = setImmediate
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With