Skip to content
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

Allow fluid rendering of dynamic children #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rsquires
Copy link

No description provided.

@@ -114,7 +114,7 @@ class Masonry extends React.Component {
const itemsInColumns = new Array(currentColumnCount);

// 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
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
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
Copy link
Owner

paulcollett commented Jan 17, 2020 via email

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