Last active
February 9, 2018 18:50
-
-
Save miwillhite/90e4fdc5547b9f1113bdb34cc8caca89 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
// :: ReactComponent -> ReactComponent -> ReactComponent | |
const concatR = A => B => | |
({ ...props, children }) => | |
<> | |
<A { ...props } { ...children } /> | |
<B { ...props } { ...children } /> | |
</> | |
// :: ReactComponent | |
const EmptyComponent = <></>; | |
// :: ReactComponent | |
export const FormTransactor = | |
pipe([ // Some notes about what happens here: | |
reduce(concatR, EmptyComponent), // 1. Take the input list of components and concat them (as siblings) | |
lift2(nest)(enhance(<form />), // 2. *lift* a binary nest fn, passing in the enhanced form as the first arg | |
name('FormTransactor'), // 3. name the entire thing (enhanced form with nested children) | |
])([ | |
Administration, | |
FieldList, | |
FormTransactorControls, | |
]); | |
// Renders something like: | |
// | |
// <FormTransactor> | |
// <Administration { ...props } { ...children } /> | |
// <FieldList { ...props } { ...children } /> | |
// <FormTransactorControls { ...props } { ...children } /> | |
// </FormTransactor> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment