usePreferences Hook Ignores Filter
Hi team,
I'm using the usePreferences hook from the Novu React Native SDK, and I’ve encountered a couple of issues:
1) Filter Not Applied:
When passing filter parameters (e.g., tags: [tag]), the hook still returns all preferences, not just those matching the filter.
const { preferences, isLoading } = usePreferences({
filter: {
tags: [tag],
},
});
2) Potential Caching Issue:
When I open the screen that uses this hook, navigate away, and then return to it, the hook doesn't seem to re-run. It returns undefined, and isLoading is false. This feels like some stale cache is being returned, and the hook is not refetching fresh data.
Let me know if this is expected behavior or if there's a recommended workaround. Otherwise, it might be worth treating this as a bug.
Thanks in advance!
8 Replies
Hi Yurii
usePreferences
hook returns a refetch function. You will need to use that function to refetch the data again
So, it will resolve the second issue, but still filter not applied. It's the main problem
Checking again from my side
@yurii_kluban
Its working for me as expected
I have applied filter with tag value
events:attend
.
I have 6 workflows with this tag, and usePreference hook is returning global + 6 workflow preferenceHere my logs, I do the same as you.
One point that is wondering me, I do not see in the request params my attached filters for some reason, but I think I should.
Using "@novu/react-native": "3.6.0"




i was testing in
@novu/react
. Let me quickly check with react native sdk. I thought, it's behaviour will be similar to @novu/react-native
please, let me know. The usage so simple, that's why I'm sure I'm doing it in the correct way 😌
@yurii_kluban, you just advanced to level 1!