dillon1000/react
Commit
Browse files Allow iterables in traverseAllChildren
This lets you use any kind of iterable as a container of react child elements. It also preserves keys when possible if the iterable is keyed.
* Use an ES6 Map or Set to hold children.
* Use an Immutable-js collection to hold children.
* Use a function* which yields children.
Concretely, this removes the necessary conversion to JS objects if you're mapping over Immutable-js collections to get children, i.e.:
```
<div>
{myImmutable.map(val => <span>{val}</span>).toJS()
</div>
```
Now we can remove the `toJS()` and the intermediate allocation along with it.
This also cleans up the traverseAllChildrenImpl method.Changed paths5 files
First-parent comparisonsrc/core/ReactElementValidator.js ModifiedM src/core/__tests__/ReactElement-test.js ModifiedM src/utils/__tests__/traverseAllChildren-test.js ModifiedA src/utils/getIteratorFn.js AddedM src/utils/traverseAllChildren.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…