solid-outside-click-handler
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

solid-outside-click-handler

npm npm version npm downloads sponsors

Detect and handle clicks outside a Solid component.

Usage

Installation

npm install solid-outside-click-handler --save
yarn add solid-outside-click-handler ## or in yarn

Example

Using the HOC

import { Component } from 'solid-js'
import { OutsideClickHandler } from 'solid-outside-click-handler'


const Page: Component = () => (
  <OutsideClickHandler
    onOutsideClick={ () => console.log('Outside!') }
  >
    <div>Hello ✨</div>
  </OutsideClickHandler>
)

Using the hook

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>
  )
}

License

MIT

Package Sidebar

Install

npm i solid-outside-click-handler

Weekly Downloads

18

Version

0.1.0

License

MIT

Unpacked Size

14 kB

Total Files

9

Last publish

Collaborators

  • diragb