2929} = require ( 'ReactPortal' ) ;
3030
3131var ReactFiber = require ( 'ReactFiber' ) ;
32- var ReactReifiedYield = require ( 'ReactReifiedYield' ) ;
3332var ReactTypeOfSideEffect = require ( 'ReactTypeOfSideEffect' ) ;
3433var ReactTypeOfWork = require ( 'ReactTypeOfWork' ) ;
3534
@@ -53,11 +52,6 @@ const {
5352 createFiberFromPortal,
5453} = ReactFiber ;
5554
56- const {
57- createReifiedYield,
58- createUpdatedReifiedYield,
59- } = ReactReifiedYield ;
60-
6155const isArray = Array . isArray ;
6256
6357const {
@@ -316,21 +310,16 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
316310 yieldNode : ReactYield ,
317311 priority : PriorityLevel
318312 ) : Fiber {
319- // TODO: Should this also compare continuation to determine whether to reuse?
320313 if ( current == null || current . tag !== YieldComponent ) {
321314 // Insert
322- const reifiedYield = createReifiedYield ( yieldNode ) ;
323315 const created = createFiberFromYield ( yieldNode , priority ) ;
324- created . type = reifiedYield ;
316+ created . type = yieldNode . value ;
325317 created . return = returnFiber ;
326318 return created ;
327319 } else {
328320 // Move based on index
329321 const existing = useFiber ( current , priority ) ;
330- existing . type = createUpdatedReifiedYield (
331- current . type ,
332- yieldNode
333- ) ;
322+ existing . type = yieldNode . value ;
334323 existing . return = returnFiber ;
335324 return existing ;
336325 }
@@ -411,9 +400,8 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
411400 }
412401
413402 case REACT_YIELD_TYPE : {
414- const reifiedYield = createReifiedYield ( newChild ) ;
415403 const created = createFiberFromYield ( newChild , priority ) ;
416- created . type = reifiedYield ;
404+ created . type = newChild . value ;
417405 created . return = returnFiber ;
418406 return created ;
419407 }
@@ -474,7 +462,10 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
474462 }
475463
476464 case REACT_YIELD_TYPE : {
477- if ( newChild . key === key ) {
465+ // Yields doesn't have keys. If the previous node is implicitly keyed
466+ // we can continue to replace it without aborting even if it is not a
467+ // yield.
468+ if ( key === null ) {
478469 return updateYield ( returnFiber , oldFiber , newChild , priority ) ;
479470 } else {
480471 return null ;
@@ -527,9 +518,9 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
527518 }
528519
529520 case REACT_YIELD_TYPE : {
530- const matchedFiber = existingChildren . get (
531- newChild . key === null ? newIdx : newChild . key
532- ) || null ;
521+ // Yields doesn't have keys, so we neither have to check the old nor
522+ // new node for the key. If both are yields, they match.
523+ const matchedFiber = existingChildren . get ( newIdx ) || null ;
533524 return updateYield ( returnFiber , matchedFiber , newChild , priority ) ;
534525 }
535526
@@ -561,7 +552,6 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
561552 switch ( child . $$typeof ) {
562553 case REACT_ELEMENT_TYPE :
563554 case REACT_COROUTINE_TYPE :
564- case REACT_YIELD_TYPE :
565555 case REACT_PORTAL_TYPE :
566556 const key = child . key ;
567557 if ( typeof key !== 'string' ) {
@@ -1019,34 +1009,22 @@ function ChildReconciler(shouldClone, shouldTrackSideEffects) {
10191009 yieldNode : ReactYield ,
10201010 priority : PriorityLevel
10211011 ) : Fiber {
1022- const key = yieldNode . key ;
1012+ // There's no need to check for keys on yields since they're stateless.
10231013 let child = currentFirstChild ;
1024- while ( child ) {
1025- // TODO: If key === null and child.key === null, then this only applies to
1026- // the first item in the list.
1027- if ( child . key === key ) {
1028- if ( child . tag === YieldComponent ) {
1029- deleteRemainingChildren ( returnFiber , child . sibling ) ;
1030- const existing = useFiber ( child , priority ) ;
1031- existing . type = createUpdatedReifiedYield (
1032- child . type ,
1033- yieldNode
1034- ) ;
1035- existing . return = returnFiber ;
1036- return existing ;
1037- } else {
1038- deleteRemainingChildren ( returnFiber , child ) ;
1039- break ;
1040- }
1014+ if ( child ) {
1015+ if ( child . tag === YieldComponent ) {
1016+ deleteRemainingChildren ( returnFiber , child . sibling ) ;
1017+ const existing = useFiber ( child , priority ) ;
1018+ existing . type = yieldNode . value ;
1019+ existing . return = returnFiber ;
1020+ return existing ;
10411021 } else {
1042- deleteChild ( returnFiber , child ) ;
1022+ deleteRemainingChildren ( returnFiber , child ) ;
10431023 }
1044- child = child . sibling ;
10451024 }
10461025
1047- const reifiedYield = createReifiedYield ( yieldNode ) ;
10481026 const created = createFiberFromYield ( yieldNode , priority ) ;
1049- created . type = reifiedYield ;
1027+ created . type = yieldNode . value ;
10501028 created . return = returnFiber ;
10511029 return created ;
10521030 }
0 commit comments