Detect and handle clicks outside a Solid component.
npm install solid-outside-click-handler --save
yarn add solid-outside-click-handler ## or in yarn
import { Component } from 'solid-js'
import { OutsideClickHandler } from 'solid-outside-click-handler'
const Page: Component = () => (
<OutsideClickHandler
onOutsideClick={ () => console.log('Outside!') }
>
<div>Hello ✨</div>
</OutsideClickHandler>
)
import { Component, onMount } from 'solid-js'
import { useOutsideClickHandler } from 'solid-outside-click-handler'
const Page: Component = () => {
let ref
onMount(() => {
useOutsideClickHandler(ref, () => console.log('Outside!'))
})
return (
<div ref={ ref }>Hello ✨</div>
)
}
MIT