withClickOutside
The High Order Component which allows you to detect the current click is outside or inside of a component.
Table Content
Installation
npm
npm i with-click-outside
yarn
yarn add with-click-outside
Parameters
withClickOutside retrieves 2 params.
React Component
node
id
string
Usage
;; const WrappedComp = ;
You can check out the basic demo here: https://codesandbox.io/s/yj9m75734j
;; ; Component { super; thisstate = open: false ; } { if nextPropsoutside !== thispropsoutside this; } { this; }; { const open = thisstate; const outside id = thisprops; return <div> <p>outside ? 'outside' : 'inside'</p> <div id=id> <button onClick=thistoggle>toggle</button> open && !outside && <ul> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> </div> </div> ; }const WrappedDropDown = ;ReactDOM;