-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Open
Labels
Description
📜 Description
I'm using usePreferences to fetch preferences, error and isLoading states like below:
const { preferences, error, isLoading, refetch } = usePreferences();When this component is mounted for the first time then the state change looks like below:
| State | Initial | Afterwards |
|---|---|---|
isLoading |
true |
false |
error |
undefined |
undefined |
preferences |
undefined |
A valid array with global and workflow specific preferences |
But when this component unmounts and re-mounts again then the state change looks like below:
| State | Initial | Afterwards |
|---|---|---|
isLoading |
true |
false |
error |
undefined |
undefined |
preferences |
undefined |
undefined |
Basically I stuck in a broken state where we have no data, no error, and we're not loading.
👟 Reproduction steps
- Open the component that uses
usePreferencesto fetch the preferences data - it fetches the preferences correctly the first time. - Unmount this component, remove completely from the DOM.
- Open the same component again -
preferencesvalue is not set correctly and it remainsundefined.
👍 Expected behavior
The preferences value should be correctly set when the component re-mounts - if the value is fetches every time then it should be fetched, if the value is set from the cache then it should be hydrated correctly.
👎 Actual Behavior with Screenshots
Not required.
Novu version
Novu SaaS
npm version
3.11.0
node version
No response
📃 Provide any additional context for the Bug.
I'm not sure if this is helpful but I'm using useNotifications for fetching notification in the same way and it works perfectly.
👀 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?
- I have read the Contributing Guidelines
Are you willing to submit PR?
None
Reactions are currently unavailable