Real time events in React

Hello support, so I'm trying to integrate real-time events in React using useNova hook. here is my code
useEffect(() => {
const fn = ({ result }: { result: Notification }) => {
// console.log('new notification =>', result)
toast.info(result.subject, {
id: result.id,
description: result.body,
position: 'bottom-right',
})
}
if (!novu) return
novu.on('notifications.notification_received', fn)

return () => {
novu.off('notifications.notification_received', fn)
}
}, [novu])
useEffect(() => {
const fn = ({ result }: { result: Notification }) => {
// console.log('new notification =>', result)
toast.info(result.subject, {
id: result.id,
description: result.body,
position: 'bottom-right',
})
}
if (!novu) return
novu.on('notifications.notification_received', fn)

return () => {
novu.off('notifications.notification_received', fn)
}
}, [novu])
I'm getting that novu.off is deprecated, is there any changes?
1 Reply
Dima
Dima6mo ago
Hi Omar

Looks like novu.off is deprecated, but still can be used. Let me check with my team on this

Did you find this page helpful?