React Native Support
See original GitHub issueFirst 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 thewindow
object exists, butdocument
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:
- Created 7 years ago
- Reactions:4
- Comments:14 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates on this issue?
@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.