#Notifications center v0.10.1 TypeError

1 messages · Page 1 of 1 (latest)

surreal stratus
#

@keen pike is facing the following:

TypeError: Cannot read properties of null (reading 'notifications')
on the notifications center v0.10.1

Has anyone else encountered that?

@keen pike Can you add anything else that may be relevant to troubleshoot this?

keen pike
#

I can get some screenshots when I get to work 🙂

surreal stratus
full prism
#

@keen pike it would be nice if you can provide more context

keen pike
#

Currently running in Remix, using @novu/notifications-center: 0.10.1 When using the useNotifications() hook, I get the following error:

TypeError: Cannot read properties of null (reading 'notifications')

example code:

const { notifications, refetch, markAsSeen, fetching, markAsRead } = useNotifications();
...
  useEffect(() => {
    if (!fetching) {
      if (notifications) {
        notifications.forEach((n) => {
          if (!n.seen) {
            console.log(n._id, 'not seen');
            console.log(n);
            showNotification({
              id: n._id,
              title: 'Demo Notification',
              message: notificationContent(n),
              autoClose: false,
            })
          }
        })
      }
    }
  }, [notifications, markAsSeen, fetching])
...
#

hope that helps

full prism
#

which line does throw it?

keen pike
full prism
keen pike
keen pike
# full prism can you please share the stack trace?
TypeError: Cannot read properties of null (reading 'notifications')
    at j (/home/user/code/firefly/node_modules/.pnpm/@novu+notification-center@0.10.1_2zx2umvpluuhvlq44va5bta2da/node_modules/@novu/notification-center/src/hooks/use-notifications.hook.ts:14:36)
    at AppHeader (/home/user/code/firefly/apps/web/app/components/layout/AppHeader.tsx:20:57)
    at renderWithHooks (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:5662:16)
    at renderIndeterminateComponent (/home/wdhodges/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:5735:15)
    at renderElement (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:5950:7)
    at renderNodeDestructiveImpl (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:6108:11)
    at renderNodeDestructive (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:6080:14)
    at renderNode (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:6263:12)
    at renderChildrenArray (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:6215:7)
    at renderNodeDestructiveImpl (/home/user/code/firefly/node_modules/.pnpm/react-dom@18.2.0_react@18.2.0/node_modules/react-dom/cjs/react-dom-server-legacy.node.development.js:6145:7)

sorry that took me longer than I wanted it to take

full prism
#

to me it seems like you are trying to use the useNotifications hook outside the NovuProvider context
can you check that?