Error on React Native when using Auth

Issue Description: What’s happening?

Reproduce the Issue: What steps can someone take to replicate the problem?

Hello,

When I used 8base on my React Native app, Auth doesn’t work showing an error message.

I followed Quick Start section on the official docs.
First, it worked well on the web (as the docs covers.)

But when I tried the same thing with React Native, just referring to Auth or withAuth in codes after imports caused the error below and the app crashed.

import { Auth } from '@8base/auth';
import { withAuth } from '@8base/app-provider';

withAuth(Component)
Auth.createClient({...})

super is not valid in this context.
* [native code]:null in eval
- node_modules/metro/src/lib/bundle-modules/injectUpdate.js:65:9 in inject
* [native code]:null in forEach
- node_modules/metro/src/lib/bundle-modules/injectUpdate.js:70:23 in injectUpdate
- node_modules/metro/src/lib/bundle-modules/HMRClient.js:40:21 in on$argument_1
- node_modules/eventemitter3/index.js:202:37 in emit
- node_modules/metro/src/lib/bundle-modules/WebSocketHMRClient.js:72:20 in _ws.onmessage
- node_modules/event-target-shim/dist/event-target-shim.js:818:39 in EventTarget.prototype.dispatchEvent
- node_modules/react-native/Libraries/WebSocket/WebSocket.js:232:27 in _eventEmitter.addListener$argument_1
- node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:190:12 in emit
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:436:47 in __callFunction
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:26 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:17 in __guard$argument_0
* [native code]:null in callFunctionReturnFlushedQueue

I’m running my app on expo.
This error occurred when I run on both a device and simulator.

its dependencies in package.json

  "dependencies": {
    "@8base/api-client": "^1.1.0",
    "@8base/app-provider": "^0.37.2",
    "@8base/react-sdk": "^0.37.2",
    "@apollo/client": "^3.0.0-beta.41",
    "@react-native-community/masked-view": "0.1.5",
    "@react-navigation/native": "^5.1.3",
    "@react-navigation/stack": "^5.2.6",
    "apollo-client": "^2.6.8",
    "expo": "~36.0.0",
    "graphql": "^14.6.0",
    "graphql-tag": "^2.10.3",
    "react": "~16.9.0",
    "react-apollo": "3.1.1",
    "react-dom": "~16.9.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz",
    "react-native-gesture-handler": "~1.5.0",
    "react-native-paper": "^3.6.0",
    "react-native-reanimated": "~1.4.0",
    "react-native-safe-area-context": "0.6.0",
    "react-native-screens": "2.0.0-alpha.12",
    "react-native-web": "~0.11.7",
    "recompose": "^0.30.0"
  },

Anything I’m missing or is this a known issue?
I suppose Authentication is still work-in-progress because I felt the documentation doesn’t cover all information developers need, but I just want to know I can solve this problem on my side or not.

Expected Behavior: What did you expect to happen?

No error occurs.

Actual Behavior: What actually happened?

The error occurs.

More details or screenshot

N/A

Were you able to resolve this @oisu Running into the same issue!

Hey there - our SDKs were designed for web as we don’t really have support for RN. I’ll work at putting together a tutorial for mobile authentication using React Native + 8base.

1 Like

That would be awesome! Even Bacon and Expo have this example with expo-auth-session https://github.com/expo/examples/tree/master/with-auth0.

Trying to get this example to work along with Apollo V3

@sebastian.scholl

Was a tutorial for react-native ever created? I’m running into the same error here as @sjohnson

and looks like this npm package has now been abandoned.

Hey @MarkLyck - yeah we haven’t had the capacity or expertise to focus on react-native. Any implementation currently will have to be self-developed/supported, though community questions will be answered as best as possible.