TheSpicyMeatball / react-nanny

Utils to manage your React Children
Other
85 stars 4 forks source link

getChildrenByTypeDeep when children includes an array #16

Closed bitttttten closed 2 years ago

bitttttten commented 2 years ago

I am using getChildrenByTypeDeep, and I'm not managing to find elements in children that are in an array.

<MyComponent>
    <A />
    {data.map(() => <B />)}
    {data.map(() => <C />)}
    <D />
</MyComponent>

In the above example and inside MyComponent, getChildrenByTypeDeep(MyComponent.children, [A, B, C, D]) will manage to find A and D, but not B or C.

So children is an array of 4, the 2nd and 3rd items in that array being more arrays of children. Not sure if this is a feature, or a bug, so I guess my question could: how do I do this?

TheSpicyMeatball commented 2 years ago

Hi @bitttttten ,

Thank you for reporting this bug. Your expectation that it should work was correct. It was a bug that was introduced in 2.14.0. I have just released a new version 2.14.1 that should resolve the issue. Please let me know if you have any issues related to this!