"use client"; import { Portal } from "@radix-ui/react-portal"; import clsx from "clsx"; import React from "react"; import { useReducer, useRef } from "react"; import { useHover } from "react-aria"; import ToastContainer from "./ToastContainer"; import styles from "./toasts.module.css"; import useToasts from "./useToasts"; function useForceUpdate(): () => void { return useReducer(() => ({}), {})[1]; } const ToastArea = () => { const { hoverProps, isHovered } = useHover({}); const { current } = useToasts(); const messages = current?.messages ?? []; const heights = useRef([]); const forceUpdate = useForceUpdate(); return (
1, })} > {messages.map((e, i) => { return ( { current?.removeToastByKey(e.key); }} type={e.type} preserve={e.preserve} action={e.action} cancelAction={e.cancelAction} id={e.key} onMount={forceUpdate} /> ); })}
); }; export default ToastArea;