Skip to content

[wip] Make TideComponent use keyPath prop instead of {...props} #22

@lwakefield

Description

@lwakefield

My thoughts are still forming on this, so bear with me.

The outcome that I would like to achieve out of this is something like follows:

<Product productId={'asd'} /> // would render a product using global state calculated from productId

As far as I can tell, we cannot pass data from tide that is calculated based on props. The only option we have is to pass data from tide that is based on data from tide.

So with the above example, we would need to do something like <Product productData={...} /> where productData is passed down a number of levels.

I think this can be addressed, based on something similar to a connector described here. The general idea is that instead of passing props into a <TideComponent /> and using all props as the keypaths, you use a keyPath prop. Since keyPath might have some mapping fns, then you can use other props passed into the component as well. something like this.

One of the large issues with passing props all the way down, is that changing a prop at a higher level, forces updates all the way down the tree, which can be very expensive.

Is this already handled by mapProps? If this is the case, we should document that!

I am wondering if what the implications here are. I am not sure whether this is something that could be done in a backward compatible manner, but I will think about this some more.

I apologize for slightly rambling thoughts. I think a PR is the best way to demonstrate what I mean here!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions