detect system theme, toast performance opt.
This commit is contained in:
@@ -3,17 +3,17 @@ import { useRecoilState } from 'recoil'
|
||||
import { toastListState } from '../atoms/toast'
|
||||
|
||||
export const useToast = () => {
|
||||
const [toasts, setToasts] = useRecoilState(toastListState)
|
||||
const [, setToasts] = useRecoilState(toastListState)
|
||||
|
||||
return {
|
||||
pushMessage: (message: string, severity?: AlertColor) => {
|
||||
setToasts([{
|
||||
setToasts(state => [...state, {
|
||||
open: true,
|
||||
message: message,
|
||||
severity: severity,
|
||||
autoClose: true,
|
||||
createdAt: Date.now()
|
||||
}, ...toasts])
|
||||
}])
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user