react-trap

1.1.0 • Public • Published

react-trap

Detect dom events inside or outside an element

NPM JavaScript Style Guide

Live Demo, playground & DOCS

Install

npm install --save react-trap

Usage

import React from 'react'
import Trap from 'react-trap'
 
class App extends React.Component {
  render () {
    return (
      <Trap event="click">
        {
          (trapped, ref) => (
            <div ref={ref}>
              {trapped ? "I'm focused" : "I'm out of focus"}
            </div>
          )
        }
      </Trap>
    )
  }
}

License

MIT © sag1v

Package Sidebar

Install

npm i react-trap

Weekly Downloads

5

Version

1.1.0

License

MIT

Unpacked Size

41.7 kB

Total Files

6

Last publish

Collaborators

  • sag1v