dillon1000/react
Commit
Browse files Flatten Children A Single Level
This expects static children as additional arguments to the constructor and flattens any array arguments one level deep. Component(props, child1, child2, arrayOfChildren, child3) -> .props.children = [child1, child2, ...arrayOfChildren, child3] This can avoid an additional heap allocation for the unflat array. It allows you to pass nested arrays and objects like you used to. Those aren't immediately flattened. That makes this a fairly safe change. Passing a dynamic array without key properties will yield a warning (once). Might consider throwing later. Once we change the transpiler to use the new syntax, you'll end up with a single flat array in normal usage. This doesn't actually update the JSX transform.
Changed paths5 files
First-parent comparisonsrc/core/ReactComponent.js ModifiedM src/core/ReactCompositeComponent.js ModifiedM src/core/ReactDOM.js ModifiedM src/core/__tests__/ReactMultiChildReconcile-test.js ModifiedM src/utils/flattenChildren.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…