Skip to content

Detect dom events inside or outside an element

Notifications You must be signed in to change notification settings

sag1v/react-trap

Repository files navigation

react-trap

Detect dom events inside or outside an element

NPM JavaScript Style Guide

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

About

Detect dom events inside or outside an element

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published