Skip to content

Instantly share code, notes, and snippets.

@miwillhite
Last active February 9, 2018 18:50
Show Gist options
  • Save miwillhite/90e4fdc5547b9f1113bdb34cc8caca89 to your computer and use it in GitHub Desktop.
Save miwillhite/90e4fdc5547b9f1113bdb34cc8caca89 to your computer and use it in GitHub Desktop.
// :: 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