对于迭代/映射反应的孩子,哪种方法更好/更安全,一般建议? this.props.children.map(c = spannew child/span); 要么 React.Children.map(c = spannew child/span); React.Children.map更好,因为它处理null和undefined案例
this.props.children.map(c => <span>new child</span>);
要么
React.Children.map(c => <span>new child</span>);React.Children.map更好,因为它处理null和undefined案例.
If children is null or undefined, returns null or undefined rather than an array.