Skip to content

Commit

Permalink
use React.Children.count for counting children (#28991)
Browse files Browse the repository at this point in the history
Summary:
just a minor change - uses the [count api](https://reactjs.org/docs/react-api.html#reactchildrencount)

> Returns the total number of components in children, equal to the number of times that a callback passed to map or forEach would be invoked.

## Changelog

not needed I think
Pull Request resolved: #28991

Test Plan: tested locally

Differential Revision: D21794081

Pulled By: TheSavior

fbshipit-source-id: bf6d11b2bc854d938aed7268911f89a00bb3f596
  • Loading branch information
vonovak authored and facebook-github-bot committed May 29, 2020
1 parent 163ec92 commit 92160f3
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions Libraries/Components/TextInput/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,7 @@ function InternalTextInput(props: Props): React.Node {
const style = [props.style];
const autoCapitalize = props.autoCapitalize || 'sentences';
let children = props.children;
let childCount = 0;
React.Children.forEach(children, () => ++childCount);
const childCount = React.Children.count(children);
invariant(
!(props.value && childCount),
'Cannot specify both value and children.',
Expand Down

0 comments on commit 92160f3

Please sign in to comment.