1.2.6 • Published 4 years ago

reacthook-withclickoutside v1.2.6

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

reacthook-withclickoutside

Installation:

npm install --save-dev reacthook-withclickoutside

Parameter:

propertyDescriptionExample
handlerIf click is outside, this function will execute() => { //Do something here...}
excludeContainerIdsSome frameworks render something like menu-item or select-option in different container, therefore you must exclude them.'id1','id2'
excludeQuerySelectorsSometime different container doesn't have id so you can replace it with querySelector'selector1','selector2'
isInitContainersAllTimesSet it false to find all containers once time.true or false

Usage:

import withClickOutside from 'reacthook-withclickoutside'
export default function Component() {
  const ref = withClickOutside({
        handler: () => {
            setIsOpen(!isOpen)
        },
        excludeContainerIds: ["id1", "id2"],
        excludeQuerySelectors: ["div.class-name", "div[attribute='value']"]
    })
  render(
    <div ref={refClickOutside}></div>
  )
}
1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago