use `onClose` instead of `onChange` for close callback (#3116)

zio/stable
Hailey 2024-03-05 16:55:20 -08:00 committed by GitHub
parent 20b88f43e2
commit 57854e6fc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 22 deletions

View File

@ -119,9 +119,7 @@ export function Outer({
[open, close], [open, close],
) )
const onChange = React.useCallback( const onCloseInner = React.useCallback(() => {
(index: number) => {
if (index === -1) {
Keyboard.dismiss() Keyboard.dismiss()
try { try {
closeCallback.current?.() closeCallback.current?.()
@ -132,14 +130,10 @@ export function Outer({
} finally { } finally {
closeCallback.current = undefined closeCallback.current = undefined
} }
setDialogIsOpen(control.id, false) setDialogIsOpen(control.id, false)
onClose?.() onClose?.()
setOpenIndex(-1) setOpenIndex(-1)
} }, [control.id, onClose, setDialogIsOpen])
},
[onClose, setOpenIndex, setDialogIsOpen, control.id],
)
const context = React.useMemo(() => ({close}), [close]) const context = React.useMemo(() => ({close}), [close])
@ -167,7 +161,7 @@ export function Outer({
backdropComponent={Backdrop} backdropComponent={Backdrop}
handleIndicatorStyle={{backgroundColor: t.palette.primary_500}} handleIndicatorStyle={{backgroundColor: t.palette.primary_500}}
handleStyle={{display: 'none'}} handleStyle={{display: 'none'}}
onChange={onChange}> onClose={onCloseInner}>
<Context.Provider value={context}> <Context.Provider value={context}>
<View <View
style={[ style={[