TheSpicyMeatball / react-nanny

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

Get children which are elements #5

Closed LoganDark closed 3 years ago

LoganDark commented 3 years ago

Makes sure all children were made by React.createElement, i.e. you can safely access their props and component and stuff. I'm making a component that wants to preserve props of its children, but modify a couple (style and className).

TheSpicyMeatball commented 3 years ago

I'm not sure I follow. Can you provide a simple code example of what you're trying to accomplish?

LoganDark commented 3 years ago

I'm not sure I follow. Can you provide a simple code example of what you're trying to accomplish?

I managed to do it using getChildren(children, isElement), where isElement is from react-is, if that helps you understand.

TheSpicyMeatball commented 3 years ago

I think the way you did it is likely the best way unless there's a shortcoming with that which I'm missing?

LoganDark commented 3 years ago

Yeah, I solved my issue

TheSpicyMeatball commented 3 years ago

Cool, thanks for the clarification.