Skip to content

Cannot read properties of undefined (reading 'context') #102

Description

@hosseintalebi

I'm trying to use RollbarContext and it's giving me an error on its componentDidMount function as it's trying to access rollbar.options.payload.context (see here). Looking at the rollbar.options object, there's no payload.

image

This is how I'm using the <RollbarContext>:

const rollbarConfig = {
  accessToken: '<token>',
  environment: 'testenv',
};
...
    <Provider config={rollbarConfig}>
       <ErrorBoundary>
        <Router>
          <Route path={rootPath}>
            <Switch>
              {Object.entries(routes).map(([path, route]) => {
                return (
                  <RollbarContext context={path}>
                    <LazyRoute ... />
                  </RollbarContext>
                );
              })}
              <Redirect from="*" to="/app/404" />
            </Switch>
          </Route>
        </Router>
      </ErrorBoundary>
    </Provider>

I'm using the following versions of the libraries:

  • rollbar@2.26.2
  • @rollbar/react@0.11.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions