## Alert
Usage example:
```typescript jsx
import { MutableRefObject, useEffect, useRef, useState } from "react";
import {
Alert,
AlertItemType,
VStack
} from '@project-1114/ui-kit'
const warnAlert: AlertItemType = {
title: 'Alert 1',
showTime: 1500,
type: "warning",
body: (
Текст предупреждения!
)
}
const errorAlert: AlertItemType = {
title: 'Alert 2',
showTime: 2500,
type: "error",
body: (
Невозможно совершить действие!
)
}
const successAlert: AlertItemType = {
title: 'Alert 3',
showTime: 1000,
type: "success",
body: (
Успешно совершено действие!
)
}
const infoAlert: AlertItemType = {
title: 'Alert 4',
showTime: 4000,
type: "info",
body: (
Some information
)
}
const defaultAlert: AlertItemType = {
title: 'Default Alert',
showTime: 3000,
type: "default",
body: (
I dont know why it is...
)
}
export function App(){
const [alerts, setAlerts] = useState([]);
const timerCleanAlerts = useRef() as MutableRefObject>;
useEffect(() => {
if(alerts.length > 0){
clearTimeout(timerCleanAlerts.current);
timerCleanAlerts.current = setTimeout(() => {
const array = [...alerts];
const elem = array.shift()
setAlerts(array);
}, alerts[0].showTime ?? 1500)
} else {
clearTimeout(timerCleanAlerts.current);
}
}, [alerts])
return (
<>
>
)
}
```