Skip to content

🐛 Bug Report: preferences value is undefined when the component using usePreferences re-mounts #10057

@nakul-bigpi

Description

@nakul-bigpi

📜 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

  1. Open the component that uses usePreferences to fetch the preferences data - it fetches the preferences correctly the first time.
  2. Unmount this component, remove completely from the DOM.
  3. Open the same component again - preferences value is not set correctly and it remains undefined.

👍 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?

Are you willing to submit PR?

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions