1- import {
2- useCallback ,
3- useContext ,
4- useEffect ,
5- useId ,
6- useMemo ,
7- useRef ,
8- } from 'react' ;
1+ import { useCallback , useContext , useEffect , useId , useRef } from 'react' ;
92import type { useDialogLazyReturn } from './types.js' ;
103import type { AsyncDialogComponent } from '../types.js' ;
114import type { useDialogOptions } from '../useDialog/types.js' ;
@@ -15,18 +8,10 @@ export function useDialogLazy<D, R, DE extends D | undefined>(
158 componentLoader : ( ) => Promise < AsyncDialogComponent < D , R > > ,
169 options ?: useDialogOptions < D , DE > ,
1710) : useDialogLazyReturn < D , R , DE > {
18- const internalId = useId ( ) ;
11+ const id = useId ( ) ;
1912 let idCount = useRef ( 0 ) ;
2013 const componentRef = useRef < AsyncDialogComponent < D , R > | null > ( null ) ;
2114
22- const id = useMemo ( ( ) => {
23- if ( options ?. customKey !== undefined ) {
24- return options . customKey ;
25- }
26-
27- return internalId ;
28- } , [ internalId , options ?. customKey ] ) ;
29-
3015 const ctx = useContext ( DialogActionsContext ) ;
3116
3217 if ( ! ctx ) {
@@ -48,11 +33,11 @@ export function useDialogLazy<D, R, DE extends D | undefined>(
4833
4934 useEffect ( ( ) => {
5035 return ( ) => {
51- if ( options ?. hideOnHookUnmount !== false ) {
36+ if ( options ?. persistOnUnmount !== true ) {
5237 ctx . hide ( id ) ;
5338 }
5439 } ;
55- } , [ id , options ?. hideOnHookUnmount ] ) ;
40+ } , [ id , options ?. persistOnUnmount ] ) ;
5641
5742 const open = useCallback (
5843 async ( data ?: D ) : Promise < R | undefined > => {
0 commit comments