-
Notifications
You must be signed in to change notification settings - Fork 227
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
Support null as a child element for ListItem #584
Conversation
Codecov Report
@@ Coverage Diff @@
## rc0.9.0 #584 +/- ##
===========================================
+ Coverage 94.36% 94.44% +0.07%
===========================================
Files 61 61
Lines 2575 2575
Branches 376 376
===========================================
+ Hits 2430 2432 +2
+ Misses 51 50 -1
+ Partials 94 93 -1
Continue to review full report at Codecov.
|
@gugu could you please provide your use case? I see what you're saying, but there might be a better way of doing what you're trying to do. Also this change requires a unit test. Thanks! |
Here is an example: return <AppListItem key={domain.id}>
<DomainNameText primaryText={ domain.hostname } />
{ this.props.editPermission ? <DomainListActions>
<AppIconButton onClick={this.handleDomainEdit(domain)} type="button"><MaterialIcon icon="edit" /></AppIconButton>
<AppIconButton onClick={this.handleDeleteDomain(domain)} type="button"><MaterialIcon icon="delete" /></AppIconButton>
</DomainListActions> : null}
</AppListItem>;}) Here is how I solved the problem (creates unnecessary DOM node): return <AppListItem key={domain.id}>
<DomainNameText primaryText={ domain.hostname } />
{ this.props.editPermission ? <DomainListActions>
<AppIconButton onClick={this.handleDomainEdit(domain)} type="button"><MaterialIcon icon="edit" /></AppIconButton>
<AppIconButton onClick={this.handleDeleteDomain(domain)} type="button"><MaterialIcon icon="delete" /></AppIconButton>
</DomainListActions> : <div />}
</AppListItem>;}) |
I see...ya that seems to be the easiest way. I was thought the best way to render list items were iterating over an array...which you could use .filter to hide a ListItem. But in the case you have one list item this makes the most sense. Can you add a unit test for this case? I will approve it then. Thanks for providing the example. |
Done |
@gugu thanks! I'm reviewing right now. Could you also sign the PR? |
Tests are passing. Once signed we can merge it in :) |
One moment, I slightly screwed up your merge with |
Ah thanks...Although I just need you to comment "I signed it" por favor |
I signed it |
Last few years React supports null as a valid child (it just ignores this element). Used mostly for conditional statements. This pull request makes ListItem support nulls