Skip to content

Instantly share code, notes, and snippets.

@deepsweet
Last active June 27, 2018 08:45
Show Gist options
  • Save deepsweet/51d090b72a7d3e9743caf62b0b502634 to your computer and use it in GitHub Desktop.
Save deepsweet/51d090b72a7d3e9743caf62b0b502634 to your computer and use it in GitHub Desktop.
"on click outside" with React and Recompose
<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();
}
}
};
})
@yyynnn
Copy link

yyynnn commented Jun 26, 2018

not working( Getting proxycomponent in ref insode onRef. What am i doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment