Detect dom events inside or outside an element
npm install --save react-trap
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>
)
}
}
MIT © sag1v