rollbar-react
rollbar-react copied to clipboard
Cannot read properties of undefined (reading 'context')
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.
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:
[email protected]@rollbar/[email protected]
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