Skip to content

🐛 Bug Report: useCounts hook crashes React Native app (Cannot read property 'filters' of undefined) #9500

@AdzeB

Description

@AdzeB

📜 Description

Using the useCounts hook from @novu/react-native in a React Native / Expo project causes the app to crash with the following error:

ERROR [TypeError: Cannot read property 'filters' of undefined]

This happens as soon as the hook is used in a component. The error appears to come from inside the Novu SDK, not from my own code, and suggests some internal object is undefined when the hook runs.

Environment:

  • React Native (Expo managed)

    • "expo": "54.0.23"

    • "react-native": "0.81.5"

  • Novu SDK:

    • "@novu/react-native": "^3.10.1"

👟 Reproduction steps

  • Create a new Expo React Native project (managed workflow).

  • Install Novu React Native SDK:

    npm install @novu/react-native

  • Initialize Novu in your app (using your Novu app ID and subscriber ID), for example in App.tsx:

import React from 'react';
import { Text, View } from 'react-native';
import { NovuProvider } from '@novu/react-native';

export default function App() {
  return (
    <NovuProvider
      applicationIdentifier="<YOUR_APP_ID>"
      subscriberId="<YOUR_SUBSCRIBER_ID>"
    >
      <MainScreen />
    </NovuProvider>
  );
}

function MainScreen() {
  return (
    <View>
      <Text>Main</Text>
    </View>
  );
}
  • In a child component rendered inside NovuProvider, use the useCounts hook:
import React from 'react';
import { Text, View } from 'react-native';
import { useCounts } from '@novu/react-native';

export function MainScreen() {
  const { data, isLoading, error } = useCounts();

  if (isLoading) return <Text>Loading…</Text>;
  if (error) return <Text>Error: {String(error)}</Text>;

  return (
    <View>
      <Text>Unread count: {data?.unseenCount}</Text>
    </View>
  );
}
  • Run the app (e.g. npx expo start).

  • The app crashes and logs:

    ERROR [TypeError: Cannot read property 'filters' of undefined]

👍 Expected behavior

The useCounts hook should work without crashing the app and should return counts (e.g. unseen/unread) according to the current subscriber and any configured filters. If something is misconfigured (e.g. missing provider), it should surface a clear error message instead of throwing Cannot read property 'filters' of undefined.

👎 Actual Behavior with Screenshots

  • As soon as useCounts is used in a component, the app crashes.

  • Error shown in the console / error overlay:

    ERROR [TypeError: Cannot read property 'filters' of undefined]

Novu version

Novu SaaS

npm version

NA

node version

22.14.0

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

Yes I am willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions