Re:React 0.14 Release Candidate
by nickpresta on Thursday September 10, 2015 @01:46PM
(#10199446)
I'm very excited about:
React.Children.map now returns plain arrays too
Before this change, we would have to do the following when checking the types of children components (in propType validation):
const childrenTypes = [];
React.Children.forEach(props.children, child => {
childrenTypes.push(child.type);
});
for (const type of childrenTypes) {
if (type !== MyComponent) {
return new Error(`Child '${type}' is not an instance MyComponent. Check render method of 'ParentComponent'.`);
}
}
It sort of made sense that map() on an opaque data structure would return the same type of data structure but in practice this was rarely useful.
Thanks, React team!