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

React + React Native compatibility #1109

Merged
merged 3 commits into from Jun 27, 2023

Conversation

waltjones
Copy link
Contributor

@waltjones waltjones commented Jun 27, 2023

Description of the change

Enables code compatibility between Rollbar-react, Rollbar.js and Rollbar-react-native, including Typescript compatibility.

Allows the same initialization, whether the target is web/JS only or JS + Native.

const rollbarReactNative = new Client({/* config */})
const rollbar = rollbarReactNative.rollbar

export default function App() {
  return (
    <Provider instance={rollbar} />
  )
}

How this works
When rollbar-react-native detects it is on a web-only target, it returns a browser-js instance. When it is on a web + native target, it returns a rollbar-react-native instance with a browser-js instance at the rollbar property.

This PR allows the app code to access the browser-js instance at the rollbar property regardless of which instance type is returned.

Type of change

  • Bug fix (non-breaking change that fixes an issue)

Related issues

Fixes https://app.shortcut.com/rollbar/story/121632

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

@waltjones waltjones merged commit 16cafa1 into master Jun 27, 2023
5 checks passed
mudetroit pushed a commit that referenced this pull request Mar 14, 2024
* self-reference rollbar object for react-native compatibility

* ts definition for react native device info

* bump ubuntu version (20.04) for ci
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.

None yet

2 participants