Skip to content

Allow fluid rendering of dynamic children - #47

Open
rsquires wants to merge 1 commit into
paulcollett:masterfrom
rsquires:dynamic-children
Open

Allow fluid rendering of dynamic children#47
rsquires wants to merge 1 commit into
paulcollett:masterfrom
rsquires:dynamic-children

Conversation

@rsquires

Copy link
Copy Markdown

No description provided.

Comment thread src/react-masonry-css.js

// Force children to be handled as an array
const items = [].concat(this.props.children || []);
const items = [].concat(this.props.children || []).filter(child => child);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what does the children you are passing look like to generate the falsy items that you then are filtering out?

I also wonder if React.Children.toArray would help with this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It creates an empty column. If you have a 3 column layout, and your children are something like [real element, falsy, real element], the middle column is empty. Maybe it's a false assumption, but I was hoping it would attempt to "left justify" the real children. I have not tried React.Children.toArray, will give that a go.

@paulcollett

paulcollett commented Jan 17, 2020 via email

Copy link
Copy Markdown
Owner

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