import React, { useState } from 'react' import { Button, ToasterContainer, Toaster, ToasterType } from 'react-icecream' export default function Demo() { const [toasts, setToasts] = useState>([]) function handleClick() { const types: ToasterType[] = ['info', 'success', 'warning', 'error'] const newToasts = [...toasts] newToasts.push({ type: types[Math.ceil(Math.random() * 4)], message: '新消息来咯,类型随机。' }) setToasts(newToasts) } return (
toaster 生成区域 {toasts.map((toast, index) => )}
) }