Skip to content

Instantly share code, notes, and snippets.

@aulisius
Created January 24, 2018 15:02
Show Gist options
  • Save aulisius/fc66920e378da1eb4f970a232b41d064 to your computer and use it in GitHub Desktop.
Save aulisius/fc66920e378da1eb4f970a232b41d064 to your computer and use it in GitHub Desktop.
const Compose = ({ children = () => null, ...chain }) => {
const composedFn = Object.entries(chain).reduce(
(acc, [renderProp, renderFn]) => props =>
renderFn(value => acc({ ...props, [renderProp]: value })),
children
);
return composedFn();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment