Skip to content

Enable js-only Expo (no native linking required)#127

Merged
waltjones merged 1 commit into
masterfrom
wj-expo-support
Jul 20, 2020
Merged

Enable js-only Expo (no native linking required)#127
waltjones merged 1 commit into
masterfrom
wj-expo-support

Conversation

@waltjones

Copy link
Copy Markdown
Contributor

Fixes: #74

This PR allows running the JS Rollbar client without the NativeClient native binding. For unejected Expo apps, or any other JS only React Native app, just npm/yarn install and add to your project:

import { Client, Configuration } from 'rollbar-react-native'
const config = new Configuration('POST_CLIENT_ITEM_ACCESS_TOKEN', {
  logLevel: 'info'
});
const rollbar = new Client(config);

Notes

This no longer throws when the native binding is missing, and omits the message about react-native link. Since RN 0.60, react-native link is no longer used (native dependencies are autolinked), so this should be fine. Especially since JS-only apps are becoming more common.

I first looked at whether Expo apps could just import the react-native target of Rollbar.js (which is what rollbar-react-native wraps for javascript support.) This would introduce dependencies (buffer, promise) that are currently handled by the rollbar-react-native wrapper. By continuing to use rollbar-react-native, the config is simpler and no new dependencies are added to rollbar.js.

For React Native Web apps, or any app that isn't a native app and runs in a browser, the browser target of Rollbar.js should be used instead. Those environments will use the browser's onerror and won't have React Native's ErrorUtils.

@waltjones waltjones merged commit 4bcf59c into master Jul 20, 2020
@waltjones waltjones deleted the wj-expo-support branch January 26, 2023 16:33
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.

Feature Request: Expo support

2 participants