Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fiber] Support iterables #8446

Merged
merged 3 commits into from
Nov 28, 2016
Merged

[Fiber] Support iterables #8446

merged 3 commits into from
Nov 28, 2016

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Nov 28, 2016

Add iterable cases to MultiChildReconcile test 0fa8116

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.

Implement iterable reconciliation in Fiber 71eefd0

This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.

Rewrite traverseAllChildren() tests against React.Children API 2b7e0a0

This function was used in React.Children and Stack.
The corresponding reconciliation functionality is being tested by ReactMultiChild tests.
So we can move these tests to ReactChildren and test its public API.

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.
This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.
This function was used in React.Children and Stack.

The corresponding reconciliation functionality is being tested by ReactMultiChild tests.

So we can move these tests to ReactChildren and test its public API.
@gaearon gaearon changed the title [Fiber][WIP] Support iterables [Fiber] Support iterables Nov 28, 2016
@@ -919,10 +1050,14 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {

const iteratorFn = getIteratorFn(newChild);
if (iteratorFn) {
const iterator = iteratorFn.call(newChild);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do this here instead of inside reconcileChildrenIterator? Flow?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd have to either get iterator function again inside of it, or pass it along. Both seemed a bit silly.

Copy link
Collaborator

@sebmarkbage sebmarkbage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't read through all the test rewrites but I trust you.

@gaearon gaearon merged commit c740345 into facebook:master Nov 28, 2016
acusti pushed a commit to brandcast/react that referenced this pull request Mar 15, 2017
* Add iterable cases to MultiChildReconcile test

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.

* Implement iterable reconciliation in Fiber

This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.

* Rewrite traverseAllChildren() tests against React.Children API

This function was used in React.Children and Stack.

The corresponding reconciliation functionality is being tested by ReactMultiChild tests.

So we can move these tests to ReactChildren and test its public API.
laurinenas pushed a commit to laurinenas/react that referenced this pull request May 28, 2018
* Add iterable cases to MultiChildReconcile test

Stack currently supports rendering iterables, but Fiber does not.

Previously we didn't have any public API tests for iterables. We have tests for traverseAllChildren() which is shared between React.Children and Stack. However Fiber doesn't currently use it, and likely won't. So this commit is a first step towards actually testing iterable support via public API. The next step will be to port traverseAllChildren() tests to test React.Children API instead.

* Implement iterable reconciliation in Fiber

This uses the same exact algorithm as array reconciliation but uses iterator to step through.

This gets reconcile tests to pass again but introduces a regression in ReactMultiChildText case which uses Maps as children. It passed before because Maps were ignored, but now it's failing because this actually runs the Map code path in Fiber. We can throw early in this case when we want to follow up on this.

* Rewrite traverseAllChildren() tests against React.Children API

This function was used in React.Children and Stack.

The corresponding reconciliation functionality is being tested by ReactMultiChild tests.

So we can move these tests to ReactChildren and test its public API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants