Giter Club home page Giter Club logo

render-props-compose's People

Contributors

gnapse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

pyrolistical

render-props-compose's Issues

Comparing with React Composer

Hi there! Really cool lib here! I recently made a similar lib, React Composer. Maybe we can join efforts and unify the community around one component?

If not, no worries. Thanks for reading โœŒ๏ธ

Support passing composed components in an object instead of a list

Enable using the composed function like this:

const CounterWithTimer = compose({
  myCounter: Counter,
  timeElapsed: Timer,
});

<CounterWithTimer>
  {({ myCounter, timeElapsed }) => (
    {/* ... */}
  )}
</CounterWithTimer>

Or alternatively the Composed component like this:

<Composed
  components={{
    clicks: Counter,
    ticks: Timer,
    position: Mouse,
  }}
>
  {({ clicks, ticks, position }) => (
    {/* ... */}
  )}
</Composed>

This allows the render prop function to expect a single props argument instead of a list of positional arguments.

If implemented, this should not replace the current way this utility works. Passing the components to compose as a list, and having the render prop function receive a list of positional arguments is still the preferred way to use this functionality.

Add tests

This will probably be a test rendering something similar to the demo, and asserting in the test that what's rendered by the render prop contains what's expected, and that all the interactions with the rendered stuff works as expected. That will effectively assert that the props from the composed components are correctly passed to the render prop, which is the main goal of this utility.

Create a live example and link to it from the README

So far we only have this, which is where I prototyped this concept before turning it into a npm package.

At first I plan to at least convert that live running example to use the composable components used in this repo's demo app (the Counter, Timer and Mouse components).

But ideally it'd be good to have a live static page showcasing this, perhaps hosted in github pages.

Support composing components that expect "render" instead of "children"

The question here is how to deal with both cases at the same time, i.e. you want to compose two components, one of which exclusively expects the render prop as render={...} while the other exclusively supports the render prop passed as children.

There's also the smaller issue of allowing the composed component itself to receive the render prop in either way. So you can call it like this:

<Composed
  components={[Counter, Timer]}
  render={(counter, timer) => (
    {/* ... */}
  )}
/>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.