dillon1000/react

Commit

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.
Browse files
Changed paths5 files
First-parent comparison
M src/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 Modified
Patch

Files changed

Rendering syntax-highlighted changes…