Last active
February 17, 2019 19:55
-
-
Save mDibyo/e144bba222eb3085b118bdd47388ada3 to your computer and use it in GitHub Desktop.
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
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