Created
January 24, 2018 15:02
-
-
Save aulisius/fc66920e378da1eb4f970a232b41d064 to your computer and use it in GitHub Desktop.
Compose Render props. Courtesy of https://gist.github.com/dralletje/51535e665a8f84e3fe59a401cbd217f1
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
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