|
|
|
|
|
by nickpresta
3929 days ago
|
|
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! |
|