Skip to content

Add support for React elements and arrays of React elements in non-children props #243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2017
Merged

Add support for React elements and arrays of React elements in non-children props #243

merged 1 commit into from
Jul 3, 2017

Conversation

le0nik
Copy link
Contributor

@le0nik le0nik commented Jul 3, 2017

Right now only children prop is traversed. It is a common pattern to pass react elements in other props. This PR's aim is to add support for this pattern. Non-array iterables are not supported because we can't know for sure how to update their elements and replacing them with arrays might break user's code and expectations.

So these patterns are supported:

// Element
<div el={<span styleName='foo' />} />

// Array of elements
<div els={[<span styleName='foo' />, <span styleName='bar' />]} />

// Array of arrays of elements(deep traversal)
<div els={[[<span styleName='foo' />], [<span styleName='bar' />]]} />

@gajus gajus merged commit b51b1f3 into gajus:master Jul 3, 2017
@gajus
Copy link
Owner

gajus commented Jul 3, 2017

Thank you

@le0nik le0nik deleted the traverse-all-props branch July 3, 2017 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants