Skip to content
This repository has been archived by the owner on Feb 24, 2021. It is now read-only.

React Native error "Can’t Find Variable Self" when import { OothClient } from 'ooth-client' #78

Open
braytonstafford opened this issue Dec 9, 2018 · 1 comment

Comments

@braytonstafford
Copy link

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. matthew-andrews/isomorphic-fetch#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.

@rpCal
Copy link

rpCal commented Feb 15, 2019

Thank you for your pull request. I've also have similar problem with this library in RN env.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants