Naively Programmable Module
    Have ideas to improve npm?Join in the discussion! »

    render-prop-composer

    1.1.0 • Public • Published

    Render Prop Composer

    Compatible with both React and Preact.

    Instead of:

    import React from "react";
     
    export default () => (
      <ContainerOne>
        {first => (
          <ContainerTwo>
            {second => (
              <React.Fragment>
                <h1>first.name</h1>
                <h1>second.description</h1>
              </React.Fragment>
            )}
          </ContainerTwo>
        )}
      </ContainerOne>
    );

    Do this:

    import React from "react";
    import CreateComposer from "render-prop-composer";
     
    const composer = CreateComposer(React.createElement, React.Fragment);
    const Composed = composer(ContainerOne, ContainerTwo);
     
    export default () => (
      <Composed>
        {props => (
          <React.Fragment>
            <h1>props.name</h1>
            <h1>props.description</h1>
          </React.Fragment>
        )}
      </Composed>
    );

    Install

    npm i render-prop-composer

    DownloadsWeekly Downloads

    3

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    5.49 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar