Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for React Native #273

Closed
azzamallow opened this issue Aug 15, 2015 · 9 comments
Closed

Add support for React Native #273

azzamallow opened this issue Aug 15, 2015 · 9 comments
Assignees

Comments

@azzamallow
Copy link

I attempted to use this package in an application I started building using React Native, unfortunately it did not work.

Requiring the package causes the react packager to hang.

var GitHubApi = require("github");

Pressing Command-R in the simulator produces (after about a minute):

Could not connect to the development server. Ensure node server is running and available on the same network - run 'nom start' from react-native root.

URL: http://localhost:8081/index.ios.bundle

The request timed out.

The packager hangs forever when attempting to debug.

I am told that not all packages run in React Native, mainly ones that designed specifically for Node JS (express for example).

@kaizensoze kaizensoze added the Status: Up for grabs Issues that are ready to be worked on by anyone label Jun 26, 2016
@kaizensoze kaizensoze removed the Status: Up for grabs Issues that are ready to be worked on by anyone label Jul 28, 2016
@Talor-A
Copy link

Talor-A commented Feb 14, 2017

In the meantime, there's react-native-github-api, though you'll have to add it manually (pretty sure it's not on npm).

@machour
Copy link

machour commented Oct 13, 2017

Here's a more up to date fork, with a single commit to add the RN compatibility: machour@1ef08ec
cc @gr2m

@gr2m gr2m self-assigned this Oct 14, 2017
@gr2m
Copy link
Contributor

gr2m commented Dec 26, 2017

I removed the fs dependency from node-github. I know it’s been a while but could you @azzamallow or someone else give it a try with react native? I haven’t built anything with it myself yet.

If it still fails, it would be helpful to create a minimal repository that I could use for testing. I’d definitely like to make it work

@gr2m gr2m added this to the v14.0.0 - Browser compatibility milestone Dec 26, 2017
@machour
Copy link

machour commented Dec 28, 2017

Gave it a try in a React Native app by just importing the lib in a screen:

import gh from 'github';

First error:
screen shot 2017-12-28 at 7 23 12 pm

workaround: manually running yarn add url in my project

Second error:
screen shot 2017-12-28 at 7 38 59 pm

The culprit seems to be this line: https://github.com/octokit/node-github/blob/master/lib/index.js#L726

RN doesn't seem to have a polyfill for http. Would it be possible to use fetch instead?

By the way, wasted so much time by testing https://www.npmjs.com/package/node-github instead of https://www.npmjs.com/package/github because of this repo name 😭😭😭😭
Would it be possible to add a clear deprecation message when installing the old package, or something? 🙏

@gr2m
Copy link
Contributor

gr2m commented Dec 29, 2017

Thanks for giving it a try!

url is not a module on npm, it’s one of Node’s core modules:
https://nodejs.org/api/url.html

RN doesn't seem to have a polyfill for http. Would it be possible to use fetch instead?

We will most likely migrate to node-fetch for the browser compatibility

By the way, wasted so much time by testing https://www.npmjs.com/package/node-github instead of https://www.npmjs.com/package/github because of this repo name 😭😭😭😭
Would it be possible to add a clear deprecation message when installing the old package, or something? 🙏

I’m sorry for the trouble :(

We will rename this module soon to @octokit/rest, so that shouldn't happen again

@stale
Copy link

stale bot commented Jan 26, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 26, 2018
@stale stale bot closed this as completed Feb 2, 2018
@gr2m
Copy link
Contributor

gr2m commented Feb 2, 2018

@octokit/rest is browser-compatible already. But I’m working towards smaller bundle sizes, including the use of fetch for browser targets. Maybe that’ll help with React Native, too? See updates here: https://github.com/octokit/rest.js/issues/620#issuecomment-362715478

@brunolemos
Copy link

React Native is a different environment than browser and node.
Made #1056 with a fix.

@gr2m
Copy link
Contributor

gr2m commented May 22, 2023

Hey I know it's been a while, but I figured folks watching this thread might be interested.

The upcoming @octokit/request is dropping node-fetch as dependency altogether. You can pass a custom fetch function as { request: { fetch } } option (see options). See octokit/request.js#586

You can try it out with

npm install @octokit/request@beta

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

No branches or pull requests

6 participants