Skip to content

Commit

Permalink
Fix dependency array (#461)
Browse files Browse the repository at this point in the history
* Fix dependency array

* small twewaks
  • Loading branch information
emilkowalski authored Jun 25, 2024
1 parent 9c2591d commit b4ffb60
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ const Toast = (props: ToastProps) => {
toastDescriptionClassname,
classNames?.description,
toast?.classNames?.description,
)}
)}
>
{toast.description}
</div>
Expand Down Expand Up @@ -534,16 +534,15 @@ const Toaster = (props: ToasterProps) => {
const lastFocusedElementRef = React.useRef<HTMLElement>(null);
const isFocusWithinRef = React.useRef(false);

const removeToast = React.useCallback(
(toastToRemove: ToastT) => {
const removeToast = React.useCallback((toastToRemove: ToastT) => {
setToasts((toasts) => {
if (!toasts.find((toast) => toast.id === toastToRemove.id)?.delete) {
ToastState.dismiss(toastToRemove.id);
}

setToasts((toasts) => toasts.filter(({ id }) => id !== toastToRemove.id))
},
[toasts],
);
return toasts.filter(({ id }) => id !== toastToRemove.id);
});
}, []);

React.useEffect(() => {
return ToastState.subscribe((toast) => {
Expand Down

0 comments on commit b4ffb60

Please sign in to comment.