Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

component type mutated after HOC #762

Open
oreporan opened this issue Nov 26, 2018 · 0 comments
Open

component type mutated after HOC #762

oreporan opened this issue Nov 26, 2018 · 0 comments

Comments

@oreporan
Copy link

oreporan commented Nov 26, 2018

I have a case where I need to iterate over the children of a component and change them based on if their type == a specific type.

So image <TabPanel> which iterates on its children to look for <Tab>
This works so long as <Tab> is directly under <TabPanel>
but if someone takes <Tab> and mutates it using any HOC, the type is no long <Tab> when I iterate over it using:

  const children = React.Children.map(childComponents, (child: React.ReactElement<Tab>) => {
   if (child.type && child.type === Tab) { // After HOC, no longer a tab
                return React.cloneElement(child, {
                    disabled,
                    size,
                });
        });

Is there anyway to tell compose to keep the old type? or extend it?

@oreporan oreporan changed the title casting component type after HOC component type mutated after HOC Nov 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant