Component: The Snackbar auto-dismissal timeout is reset on every rerender #58594
Labels
[Package] Components
/packages/components
[Status] In Progress
Tracking issues with work in progress
[Type] Bug
An existing feature does not function as intended
Currently, the Snackbar auto-dismissal timeout is reset on every rerender. The timers are reset when a notice is added or removed from the
SnackbarList
. This causes them to be visible a lot longer than expected.Why
The
onRemove
callback has a new reference on each rerender, triggers side-effect cleanup, and resets timers.Possible Solution
Omit
onDismiss
andonRemove
from the side-effect dependencies.onDismiss
callback snapshot won't change after the action is dispatched.onRemove
function. It will always return a new function.Step-by-step reproduction instructions
Expected behavior
Let's assume there is a one-second difference between message triggers.
Current behavior
cc @WordPress/gutenberg-components
The text was updated successfully, but these errors were encountered: