Skip to content

Fix assign a generated className to elements inside nested arrays #292

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
Aug 22, 2018
Merged

Fix assign a generated className to elements inside nested arrays #292

merged 1 commit into from
Aug 22, 2018

Conversation

vitaliymaz
Copy link
Contributor

My previous PR #286 broke one rare case. I'm sorry for that.

The case is when a component renders elements inside nested arrays. Example:

<div>
          {[
            [
              <p key='1' styleName='foo' />,
              <p key='2' styleName='bar' />
            ],
            [
              <p key='1' styleName='foo' />,
              <p key='2' styleName='bar' />
            ]
          ]}
        </div>

It worked before my PR because React.Children.map() recursively walks through nested arrays but lodash map doesn't do that. From another point of view, React.Children.map() flattens the array and changes the original structure.

The best solution I found is already existing function of your library called linkArray(). It also walks through arrays but unlike the React.Children.map() doesn't change the structure.

Again, I'm sorry for this regression bug.

@gajus gajus merged commit 7a87ee3 into gajus:master Aug 22, 2018
@vitaliymaz vitaliymaz deleted the fix-assign-class-in-nested-arrays branch August 22, 2018 11:20
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.

3 participants