question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React Native Support

See original GitHub issue

First off: Thank you so much for an awesome project. I’ve used this several times for testing integrations and doing demos, it’s a really great library for working with Salesforce.

I have opened up two PRs that make jsforce function correctly with React Native:

  • #571 Fixed JSONP detection by additionally checking for document, this is important because in RN JSONP should not be used, but because the window object exists, but document does not. This additional check should not present any regression to the existing JSONP support.
  • #572 Switches to using webpack. This one I am less confident about, but as far as I can tell things seem functional. Why do this? First off it’s important to note that RN does not have node core libraries, so some process must be used to load (or browserify) the various core node libraries jsforce requires. However, RN does have a require() method. Ultimately this comes down to the way that browserify attempts to resolve dependencies using require(), which is different from what webpack does. Webpack does not use require() but webpack_require() which makes all the world of difference. If there was a way to change how browserify does this, I would prefer that, but as I am not aware of one I took a stab at converting to webpack instead.

With the two above changes it is possible to use jsforce in a React Native application by simply doing:

import jsforce from 'jsforce/build/jsforce.js';

I understand the webpack change may be undesirable, but please give it some consideration as I think being able to use jsforce in React Native is a killer feature.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
darasuscommented, Mar 29, 2018

Any updates on this issue?

3reactions
stomitacommented, Nov 25, 2016

@stanlemon Interesting. I personally am not using React Native, however, I have a will to support the env as much as possible.

From curiosity I’d like to ask you why you are importing the built file, not the module name like following.

import jsforce from "jsforce";
Read more comments on GitHub >

github_iconTop Results From Across the Web

Where to get help - React Native
If you need help with your React Native app, the right place to ...
Read more >
Where To Get Support - React
Where To Get Support. React has a community of millions of developers. On this page we've listed some React-related communities that you can...
Read more >
react-native/SUPPORT.md at main - GitHub
I have a question or need help with my React Native app. If you have a coding question related to React Native, it...
Read more >
React Native - Wikipedia
React Native is an open-source UI software framework created by Meta Platforms, Inc. It is used to develop applications for Android, Android TV,...
Read more >
React Native Experts to Help, Mentor, Review Code & More
Find a freelance React Native expert for help with reviewing code, mentorship, tutoring, and other React Native help you might need.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found