Search code examples
meteorreact-nativeddp

process.nextTick is not a function (React native, ddp, meteor)


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)

Solution

  • 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!