import { ValidUUID } from "../worker/shared/types" ; import { useCollisionsProviderContext } from "../../shared/CollisionsProvider" ; import { useEffect } from "react" ; export const useCollisionEvents = ( uuid , onCollideStart ? , onCollideEnd ? ) => { const { addCollisionHandler , removeCollisionHandler } = useCollisionsProviderContext ( ) ; useEffect ( ( ) => { if ( onCollideStart ) { addCollisionHandler ( true , uuid , onCollideStart ) ; return ( ) => { removeCollisionHandler ( true , uuid ) ; } ; } } , [ uuid , onCollideStart ] ) ; useEffect ( ( ) => { if ( onCollideEnd ) { addCollisionHandler ( false , uuid , onCollideEnd ) ; return ( ) => { removeCollisionHandler ( false , uuid ) ; } ; } } , [ uuid , onCollideEnd ] ) ; } ;