mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1import React from 'react'
2
3import {DialogControlProps} from '#/components/Dialog/types'
4
5export function useAutoOpen(control: DialogControlProps, showTimeout?: number) {
6 React.useEffect(() => {
7 if (showTimeout) {
8 const timeout = setTimeout(() => {
9 control.open()
10 }, showTimeout)
11 return () => {
12 clearTimeout(timeout)
13 }
14 } else {
15 control.open()
16 }
17 }, [control, showTimeout])
18}