5

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)
Magesh khanna
  • 183
  • 1
  • 1
  • 11

3 Answers3

8

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!

Spencer Carli
  • 686
  • 3
  • 6
  • 1
    Looking up [setImmediate](https://developer.mozilla.org/en-US/docs/Web/API/Window/setImmediate) on MDN, **This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web** –  Oct 01 '19 at 22:47
1

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
}
xiechao06
  • 410
  • 6
  • 9
0

You can also use react-native-meteor package for React Native Meteor integration. https://www.npmjs.com/package/react-native-meteor check this link for documentation.

Nikhil Goswami
  • 75
  • 2
  • 13