Skip to content

Commit 92160f3

Browse files
vonovakfacebook-github-bot
authored andcommitted
use React.Children.count for counting children (#28991)
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
1 parent 163ec92 commit 92160f3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Libraries/Components/TextInput/TextInput.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1095,8 +1095,7 @@ function InternalTextInput(props: Props): React.Node {
10951095
const style = [props.style];
10961096
const autoCapitalize = props.autoCapitalize || 'sentences';
10971097
let children = props.children;
1098-
let childCount = 0;
1099-
React.Children.forEach(children, () => ++childCount);
1098+
const childCount = React.Children.count(children);
11001099
invariant(
11011100
!(props.value && childCount),
11021101
'Cannot specify both value and children.',

0 commit comments

Comments
 (0)