Skip to content

Reducing adopt generated tree depth #28

Open
@albertogasparin

Description

@albertogasparin

First thing, I really like the API of this lib, however I've noticed that for every composed component adopts adds a discrete number of intermediary components that substantially increase the React tree depth.

const Composed = adopt({
  one: ({ render }) => <One render={render} />,
  two: ({ render }) => <Two render={render} />,
});
// becomes
<Composed>
  <Adopt(one)(two)>
    <Adopt(one)>
      <Adopt>
        <one>
          <One>
            <two>
               <Two>
                 // children

This not only makes debugging the React tree harder, but if you start using it extensively to create several dozens of combined components the tree simply "explodes" and you might start having performance problems too.

It would be great if adopt could do it's magic in just one layer:

<Composed>
  <One>
    <Two>
      // children

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions