mirror of
https://github.com/Unleash/unleash.git
synced 2024-10-18 20:09:08 +02:00
27 lines
594 B
TypeScript
27 lines
594 B
TypeScript
|
import { useState } from 'react';
|
||
|
import Toast from '../component/common/Toast/Toast';
|
||
|
|
||
|
const useToast = () => {
|
||
|
const [toastData, setToastData] = useState({
|
||
|
show: false,
|
||
|
type: 'success',
|
||
|
text: '',
|
||
|
});
|
||
|
|
||
|
const hideToast = () => {
|
||
|
setToastData(prev => ({ ...prev, show: false }));
|
||
|
};
|
||
|
const toast = (
|
||
|
<Toast
|
||
|
show={toastData.show}
|
||
|
onClose={hideToast}
|
||
|
text={toastData.text}
|
||
|
type={toastData.type}
|
||
|
/>
|
||
|
);
|
||
|
|
||
|
return { toast, setToastData, hideToast };
|
||
|
};
|
||
|
|
||
|
export default useToast;
|