Skip to content

Commit

Permalink
feat(toast): use id for open status toggling (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamadoudicko committed May 27, 2023
1 parent e388990 commit 655f07d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions frontend/app/components/ui/Toast/components/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export const Toast = ({
<ToastContext.Provider value={{ publish }}>
{children}
<AnimatePresence mode="popLayout">
{toasts.map((toast, index) => {
{toasts.map((toast) => {
if (!toast.open) return;
return (
<ToastPrimitive.Root
open={toast.open}
onOpenChange={(value) => toggleToast(value, index)}
onOpenChange={(value) => toggleToast(value, toast.id)}
asChild
forceMount
key={toast.id}
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/components/ui/Toast/hooks/useToastBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { generateToastUniqueId } from "../helpers/generateToastUniqueId";
export const useToastBuilder = () => {
const [toasts, setToasts] = useState<ToastContent[]>([]);

const toggleToast = (value: boolean, index: number) => {
const toggleToast = (value: boolean, toastId: string) => {
setToasts((toasts) =>
toasts.map((toast, i) => {
if (i === index) {
toasts.map((toast) => {
if (toast.id === toastId) {
toast.open = value;
}
return toast;
Expand Down

1 comment on commit 655f07d

@vercel
Copy link

@vercel vercel bot commented on 655f07d May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.