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 for Web #122

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

daxfrost
Copy link

@daxfrost daxfrost commented May 19, 2020

What

This PR introduces React Native for Web support to pure/vanilla (not Expo) React Native projects using Rollbar, and is dependent on another PR for the Rollbar.js repository that updates its React Native target.

It's important to understand that Expo & React Native have fundamental differences, Expo is not vanilla React Native, and thus does not support any custom native libraries and cannot use this rollbar-react-native package, for this reason the ErrorUtils layer has been moved to rollbar.js repository layer and can be initialized directly - so this change will benefit Expo users - although the Configuration object still resides in this repository's ./src/Rollbar.js, and may be useful to import and use when initializing it from Expo, or be moved to Rollbar.js repo at a later stage.

The second important difference to understand is that React Native for Web is not compatible with ErrorUtils used by native app's JS layer, ErrorUtils is a custom global object of react-native itself, and designed for the JavaScriptCore headless engine that runs the JS code on Android & iOS devices. React Native for Web, however, runs on any web browser, re-using the code of the consumer's project - it can support ignoring the native libraries, unlike Expo. But it also means that it cannot depend on ErrorUtils for catching global errors, this is catered for in the dependent PR by leveraging some of the existing code used by Rollbar.js browser target.

Changes

  • Platform checks to avoid initializing the native libraries when platform is web
  • Moved ErrorUtils / JS error handlers to rollbar.js
  • Adding captureUnhandledRejections & captureUncaught into toJSON for passing configuration to Rollbar.js library

Notes

I have not understood the best way to handle the dependency in the package file for Rollbar.js package as you do releases the other PR would be a prerequisite, I hope you can help me with this @waltjones. I look forward to finalizing this as you review it for your merge consideration - I have tested it in Android, iOS and Web (all using the same repo).

@daxfrost daxfrost marked this pull request as ready for review May 20, 2020 00:00
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

Successfully merging this pull request may close these issues.

1 participant