Allow fluid rendering of dynamic children - #47
Open
rsquires wants to merge 1 commit into
Open
Conversation
paulcollett
reviewed
Jan 15, 2020
|
|
||
| // Force children to be handled as an array | ||
| const items = [].concat(this.props.children || []); | ||
| const items = [].concat(this.props.children || []).filter(child => child); |
Owner
There was a problem hiding this comment.
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?
Author
There was a problem hiding this comment.
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.
Owner
|
Sure. I think something like this would be nice for the majority of cases.
I'm just a little unsure if this is a breaking change that may impact
implementations already out there or something we can add - what do you
think? I'm curious what is being passed as a child to create those falsy
items to begin too, at least in your case?
…On Wed, Jan 15, 2020 at 7:59 AM Ross Squires ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/react-masonry-css.js
<#47 (comment)>
:
> @@ -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);
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.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#47?email_source=notifications&email_token=AAORBBWBNMBTC6TXKH2UR63Q54XGDA5CNFSM4KGFH35KYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCR3MOVY#discussion_r366958500>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAORBBUGK6CMQMNGA53RBODQ54XGDANCNFSM4KGFH35A>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.