N
Novu4w ago
loup

useCache not working

How do we cache the response from useNotifications ? Because its pretty expensive and sometime notification take 10s to be fetch so how to cache it ? Ive added :
<NovuProvider
applicationIdentifier={process.env.EXPO_PUBLIC_NOVU_APPLICATION_IDENTIFIER!}
subscriberId={session.user.id}
subscriberHash={subscriberHash}
useCache={true}
>
<NovuProvider
applicationIdentifier={process.env.EXPO_PUBLIC_NOVU_APPLICATION_IDENTIFIER!}
subscriberId={session.user.id}
subscriberHash={subscriberHash}
useCache={true}
>
But isnt working at all, each time my useNotifications is call (in a screen), the notifications are refetched...
LOG notifications number: 0
LOG notifications number: 10
LOG notifications number: 0
LOG notifications number: 10
What do I miss ?
5 Replies
Pawan Jain
Pawan Jain4w ago
@loup Could you please share react native and @novu/react-native npm package version
loup
loupOP4w ago
Im using 3.9.3 version
Pawan Jain
Pawan Jain4w ago
@loup I just tested, it is instant for me. Definitely not taking 10 seconds to load
Pawan Jain
Pawan Jain4w ago
loup
loupOP4w ago
Its actually depend, some time is quick (around 200ms, and some time around 4sec, maybe more in worst case But useCache isnt supposed to dont remake query ? and use cache ? Should be great to use it in react query instead In react native I also have some polyfill error no :
[TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.]
[TypeError: Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'.]
Im gonna try using useNovu instead of useNotifiations and manage manually the cache and the request with react query

Did you find this page helpful?