Pacote
    Preparing search index...

    Module @pacote/react-use-outside

    @pacote/react-use-outside

    version minified minified + gzip

    Hook to handle events outside React components.

    yarn add @pacote/react-use-outside
    

    Takes one or more event types to listen and an event listener function and returns a reference which can be applied to a DOM element. The provided function will be called for all listened events triggered outside the component.

    import React from 'react'
    import { useOutside } from '@pacote/react-use-outside'

    const Modal = () => {
    const ref = useOutside('click', () => {
    console.log('Clicked outside!')
    })

    return <div ref={ref}>Click outside to show console message.</div>
    }

    MIT © Luís Rodrigues.

    Functions

    useOutside