Subscribing to events
import React, { useEffect, useRef } from 'react'
const EmptyModal = ({ modal: { addListener }) => {
const onAnimateListener = useRef()
const onCloseListener = useRef()
const handleAnimation = (value) => {
console.log('Modal animatedValue:', value)
}
const handleClose = useCallback(
closingAction => {
console.log(`Modal by: ${closingAction.type} β’ ${closingAction.origin}`)
},
)
useEffect(() => {
onAnimateListener.current = addListener('onAnimate', handleAnimation)
onCloseListener.current = addListener('onClose', handleClose)
return () => {
onAnimateListener.current?.remove()
onCloseListener.current?.remove()
}
}, [])
return (
//...
)
}
export default EmptyModalLast updated