Skip to content

Instantly share code, notes, and snippets.

@mDibyo
Last active February 17, 2019 19:55
Show Gist options
  • Save mDibyo/e144bba222eb3085b118bdd47388ada3 to your computer and use it in GitHub Desktop.
Save mDibyo/e144bba222eb3085b118bdd47388ada3 to your computer and use it in GitHub Desktop.
function withHooksSupport(Component) {
return class ComponentWithHooksSupport extends Component {
render() {
const withHook = (useHook) => {
return ({ children }) => {
const returnValue = useHook();
return children(returnValue);
}
}
const WithHook = withHook(() => super.render());
return (
<WithHook>
{superRenderReturnValue => superRenderReturnValue}
</WithHook>
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment