mirror of
https://github.com/vercel/commerce.git
synced 2025-07-05 20:51:21 +00:00
24 lines
487 B
TypeScript
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
|
|
}
|
|
};
|