React Native error "Can’t Find Variable Self" when import { OothClient } from 'ooth-client'
I’m using expo to build a react-native app and ran into the error "Can’t Find Variable Self" when incorporating the ooth-client. This issue https://forums.expo.io/t/cant-find-variable-self/13547 led me to realize that just importing ooth-client was causing the error but because of the isomorphic-fetch dependency.
There are pull requests out for the isomorphic-fetch package to support react-native but no updates have been made in a long while. https://github.com/matthew-andrews/isomorphic-fetch/pull/80
I was looking at ooth-client source and there seems to be only one reference to importing the isomorphic-fetch package so I thought I'd give a crack at contributing.
In my own project I yard add cross-fetch and then changed the node_modules/ooth-client/lib/index.js source at line 38 from var fetch = require("isomorphic-fetch"); to var fetch = require("cross-fetch"); and I no longer get the "Can’t Find Variable Self" error.
I forked the ooth repo and added cross-fetch to package.json and made the change in the ooth-client source but I dont feel comfortable submitting a PR without passing tests. So I've yarn installed in the packages/ooth-client folder and done a yarn test and it fails with this error and now I'm a little lost and any help is appreciated.
src/index.ts:157:13 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof import("cross-fetch")' has no compatible call signatures.
Thank you for your pull request. I've also have similar problem with this library in RN env.