Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referential integrity for useToaster #3349

Closed
guidone opened this issue Aug 27, 2023 · 2 comments · Fixed by #3440
Closed

Referential integrity for useToaster #3349

guidone opened this issue Aug 27, 2023 · 2 comments · Fixed by #3440

Comments

@guidone
Copy link

guidone commented Aug 27, 2023

What version of rsuite are you using?

5.37.0

What version of React are you using?

18.2.0

What version of TypeScript are you using (if any)?

No response

What browser are you using?

Chrome

Describe the Bug

The useToaster hooks should keep same reference across re-renders, the code here

const useToaster = () => {
  const { toasters } = useCustom();

  return {
  // ...

creates a new instance on each render, this is voiding all useCallbacks and useMemos for which the const toaster = useToaster(); is a dependency.
In my case it's causing a cascade effect which makes the view completely unusable.

The returned object should be wrapped in a useMemo

Expected Behavior

No response

To Reproduce

No response

@SevenOutman
Copy link
Member

I'm routing this issue to @simonguo as it's related to Toaster API.

@SevenOutman SevenOutman added status: Needs Triage New issues that has not been looked into component: Toaster labels Aug 28, 2023
@simonguo simonguo added type: Bug and removed status: Needs Triage New issues that has not been looked into labels Nov 9, 2023
@simonguo
Copy link
Member

Fixed in v5.44.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants