You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I propose Array/Set should ignore tailing sub-array indices with value 0 and if the root is an only child then it has index 0 (this is currently the case, except it's broken for objects):
The first ReactNode in every Array now reconciles from and to any depth. If we want to improve Maps to reconcile in the same way then all previous indices should be discarded when a Map is encountered (possibly discarding the entire "computed name so far" even).
Pseudo-JSX showing how the new indices would be computed ([...] is discarded), all the examples at the top now reconcile correctly.
@spicyj React's optimization to drop the array allocation for 0-1 children only reconciles correctly at the lowest level. This PR allows it to work at any depth and thus extends the same courtesy to other use-cases.
Is it common? No (though it can be useful, also compare ex. 1 and 3), but I don't see that as a justification for making it inconsistent unless there's a measurable cost that we're not willing to take, but I'm quite sure there isn't.
The current state of implicit keys in React, psuedo-JSX:
I propose Array/Set should ignore tailing sub-array indices with value 0 and if the root is an only child then it has index 0 (this is currently the case, except it's broken for objects):
The first ReactNode in every Array now reconciles from and to any depth. If we want to improve Maps to reconcile in the same way then all previous indices should be discarded when a Map is encountered (possibly discarding the entire "computed name so far" even).
Pseudo-JSX showing how the new indices would be computed (
[...]
is discarded), all the examples at the top now reconcile correctly.cc @sebmarkbage
The text was updated successfully, but these errors were encountered: