commerce/src/components/hooks/useModalCommon.tsx
2021-08-27 17:50:45 +07:00

24 lines
487 B
TypeScript

import { useState } from 'react';
interface Props {
initialValue?: boolean,
}
export const useModalCommon = ({ initialValue = false }: Props) => {
const [visible, setVisible] = useState<boolean>(initialValue)
const openModal = (e?: any) => {
e && e.stopPropagation()
setVisible(true)
}
const closeModal = (e?: any) => {
e && e.stopPropagation()
setVisible(false)
}
return {
visible, openModal, closeModal
}
};