Last active
June 27, 2018 08:45
-
-
Save deepsweet/51d090b72a7d3e9743caf62b0b502634 to your computer and use it in GitHub Desktop.
"on click outside" with React and Recompose
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
<div | |
tabIndex="0" | |
ref={onRef} | |
onBlur={onWrapperBlur} | |
> | |
// ... | |
withHandlers(() => { | |
let element = null; | |
return { | |
onRef: () => (ref) => (element = ref), | |
onWrapperBlur: ({ onClickOutside }) => (e) => { | |
if (!element.contains(e.relatedTarget)) { | |
onClickOutside(); | |
} | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
not working( Getting proxycomponent in ref insode onRef. What am i doing wrong?