Skip to content

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
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
@waltjones waltjones deleted the waltjones/121632/react-react-native-compatibility branch April 7, 2025 16:20
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.

3 participants