react-native-actioncable icon indicating copy to clipboard operation
react-native-actioncable copied to clipboard

Tip for using it with Apollo 1.x

Open Mexxerio opened this issue 8 years ago • 2 comments

Just leaving this hear in case someone has the same issue as me getting it to work with Apollo 1.x:

Copy this file to somewhere in your project: https://github.com/cpunion/react-native-actioncable/blob/master/index.js

And then after global.document add the following line: global.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ = ''

if(Platform.OS == 'ios' || Platform.OS == 'android'){
  global.document = {
    addEventListener () {},
    removeEventListener () {}
  }
  global.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ = ''
}

The problem is that once there is a document, apollo checks for devtools meant for the browser and checks if global.__APOLLO_DEVTOOLS_GLOBAL_HOOK__ is undefined, then tries to give you some suggestions what devtools to use, but fails because there is no navigator.userAgent. So by just setting it to an empty string you skip the suggestion.

Mexxerio avatar Nov 08 '17 14:11 Mexxerio

Very useful. Thanks.

cpunion avatar Nov 09 '17 04:11 cpunion

This is a problem in Apollo 2 as well.

cantino avatar Dec 29 '17 20:12 cantino