Add Support for React Native for Web #122
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theConfiguration
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 ofreact-native
itself, and designed for theJavaScriptCore
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
web
captureUnhandledRejections
&captureUncaught
into toJSON for passing configuration to Rollbar.js libraryNotes
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).