rollbar-react icon indicating copy to clipboard operation
rollbar-react copied to clipboard

Cannot read properties of undefined (reading 'context')

Open hosseintalebi opened this issue 2 years ago • 3 comments

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:

hosseintalebi avatar Jul 11 '23 14:07 hosseintalebi

Running into the same issue, here's my usage:

const Chat: React.FC = () => {
  useRollbarContext('chat#list')

  return (
    <IonPage>
      <Header title='Chat' />
      <IonContent>
        <CometChatConversationsWithMessages
          isMobileView={true}
          messagesConfiguration={messageConfig}
          conversationsConfiguration={conversationConfig}
        />
      </IonContent>
    </IonPage>
  )
}

export default Chat

jerimiahmilton avatar Jul 11 '24 14:07 jerimiahmilton