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

Export provider context for class components to use #38

Merged
merged 1 commit into from
Mar 1, 2022

Conversation

waltjones
Copy link
Contributor

@waltjones waltjones commented Feb 18, 2022

Description of the change

Rollbar-react uses a React Context to make the Rollbar object available to all components. Function components can use the useRollbar hook, and this is the easiest way to get the Rollbar object.

Class components cannot use hooks, and so cannot use the useRollbar hook. React provides other ways to get the context, but the package currently lacks the necessary exports.

This PR adds the exports that allow class components to get the Rollbar object from the React Context, and adds the related type definitions so this will also work in Typescript.

Usage examples have been added to the related issue: #17

Type of change

  • New feature (non-breaking change that adds functionality)

Related issues

Fixes #17

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

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@waltjones waltjones merged commit 877e67c into main Mar 1, 2022
ijsnow pushed a commit to ijsnow/rollbar-react that referenced this pull request Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is there a way to log caught exceptions to Rollbar from class components?
2 participants