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

[Perf] Avoid React.Children.count traversal for empty state early return #15503

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
ecraig12345 marked this conversation as resolved.
Show resolved Hide resolved
"comment": "Avoid React.Children traversal for early return cases",
"packageName": "@fluentui/react-internal",
"email": "KevinTCoughlin@users.noreply.github.com",
"dependentChangeType": "patch",
"date": "2020-10-13T23:47:26.980Z"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "patch",
"comment": "Avoid React.Children traversal for early return cases",
"packageName": "@uifabric/react-cards",
ecraig12345 marked this conversation as resolved.
Show resolved Hide resolved
"email": "KevinTCoughlin@users.noreply.github.com",
"dependentChangeType": "patch",
"date": "2020-10-13T23:47:14.293Z"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
/** @jsx withSlots */
import * as React from 'react';
import { withSlots, getSlots } from '@uifabric/foundation';
import { Stack } from '@fluentui/react/lib/Stack';
import { ICardSectionComponent, ICardSectionProps, ICardSectionSlots } from './CardSection.types';

export const CardSectionView: ICardSectionComponent['view'] = props => {
const { children, ...rest } = props;
if (React.Children.count(children) < 1) {
if (children === undefined) {
KevinTCoughlin marked this conversation as resolved.
Show resolved Hide resolved
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StackItemStyles as styles } from './StackItem.styles';

const StackItemView: IStackItemComponent['view'] = props => {
const { children } = props;
if (React.Children.count(children) < 1) {
if (children === undefined) {
return null;
}

Expand Down
3 changes: 1 addition & 2 deletions packages/react-internal/src/components/Text/Text.view.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/** @jsx withSlots */
import * as React from 'react';
import { withSlots, getSlots } from '@uifabric/foundation';
import { getNativeProps, htmlElementProperties } from '../../Utilities';
import { ITextComponent, ITextProps, ITextSlots } from './Text.types';

export const TextView: ITextComponent['view'] = props => {
if (React.Children.count(props.children) === 0) {
if (props.children === undefined) {
return null;
}

Expand Down