This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { findDOMNode } from 'react-dom'; | |
type HocWrapper<P> = React.ComponentClass<P> | React.SFC<P>; | |
function withClickOutside<P, S>(Component: HocWrapper<P>): React.ComponentClass<P> { | |
class WrappedComponent extends React.Component<P, S> { | |
private handleClickOutside = e => { | |
const bounds = this.wrappedDomNode.getBoundingClientRect(); | |
const mouseX = e.clientX || e.pageX; |