Skip to content

Instantly share code, notes, and snippets.

View raminious's full-sized avatar

Ramin Mo raminious

View GitHub Profile
View create-hoc-from-render-prop.js
// handy method to create a Higher Order Component out of a
// Render Prop Component (like a Context.Consumer).
// handles, statics, displayName, refs, and value forwarding
function createHOCFromRenderProp({prop, Consumer}) {
return Component => {
function Wrapper(props, ref) {
return (
{value => <Component {...{...props, [prop]: value, ref}} />}