mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-24 20:03:41 +03:00
feat(toast): use id for open status toggling (#178)
This commit is contained in:
parent
e388990384
commit
655f07ddd3
@ -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}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user