|
8 | 8 | */
|
9 | 9 |
|
10 | 10 | import type {ReactElement} from 'shared/ReactElementType';
|
11 |
| -import type {ReactPortal, Thenable} from 'shared/ReactTypes'; |
| 11 | +import type {ReactPortal, Thenable, ReactContext} from 'shared/ReactTypes'; |
12 | 12 | import type {Fiber} from './ReactInternalTypes';
|
13 | 13 | import type {Lanes} from './ReactFiberLane.new';
|
14 | 14 | import type {ThenableState} from './ReactFiberThenable.new';
|
@@ -47,6 +47,7 @@ import {StrictLegacyMode} from './ReactTypeOfMode';
|
47 | 47 | import {getIsHydrating} from './ReactFiberHydrationContext.new';
|
48 | 48 | import {pushTreeFork} from './ReactFiberTreeContext.new';
|
49 | 49 | import {createThenableState, trackUsedThenable} from './ReactFiberThenable.new';
|
| 50 | +import {readContextDuringReconcilation} from './ReactFiberNewContext.new'; |
50 | 51 |
|
51 | 52 | // This tracks the thenables that are unwrapped during reconcilation.
|
52 | 53 | let thenableState: ThenableState | null = null;
|
@@ -594,7 +595,12 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
|
594 | 595 | newChild.$$typeof === REACT_CONTEXT_TYPE ||
|
595 | 596 | newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
|
596 | 597 | ) {
|
597 |
| - // TODO: Implement Context as child type. |
| 598 | + const context: ReactContext<mixed> = (newChild: any); |
| 599 | + return createChild( |
| 600 | + returnFiber, |
| 601 | + readContextDuringReconcilation(returnFiber, context, lanes), |
| 602 | + lanes, |
| 603 | + ); |
598 | 604 | }
|
599 | 605 |
|
600 | 606 | throwOnInvalidObjectType(returnFiber, newChild);
|
@@ -679,7 +685,13 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
|
679 | 685 | newChild.$$typeof === REACT_CONTEXT_TYPE ||
|
680 | 686 | newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
|
681 | 687 | ) {
|
682 |
| - // TODO: Implement Context as child type. |
| 688 | + const context: ReactContext<mixed> = (newChild: any); |
| 689 | + return updateSlot( |
| 690 | + returnFiber, |
| 691 | + oldFiber, |
| 692 | + readContextDuringReconcilation(returnFiber, context, lanes), |
| 693 | + lanes, |
| 694 | + ); |
683 | 695 | }
|
684 | 696 |
|
685 | 697 | throwOnInvalidObjectType(returnFiber, newChild);
|
@@ -762,7 +774,14 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
|
762 | 774 | newChild.$$typeof === REACT_CONTEXT_TYPE ||
|
763 | 775 | newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
|
764 | 776 | ) {
|
765 |
| - // TODO: Implement Context as child type. |
| 777 | + const context: ReactContext<mixed> = (newChild: any); |
| 778 | + return updateFromMap( |
| 779 | + existingChildren, |
| 780 | + returnFiber, |
| 781 | + newIdx, |
| 782 | + readContextDuringReconcilation(returnFiber, context, lanes), |
| 783 | + lanes, |
| 784 | + ); |
766 | 785 | }
|
767 | 786 |
|
768 | 787 | throwOnInvalidObjectType(returnFiber, newChild);
|
@@ -1441,7 +1460,13 @@ function createChildReconciler(shouldTrackSideEffects): ChildReconciler {
|
1441 | 1460 | newChild.$$typeof === REACT_CONTEXT_TYPE ||
|
1442 | 1461 | newChild.$$typeof === REACT_SERVER_CONTEXT_TYPE
|
1443 | 1462 | ) {
|
1444 |
| - // TODO: Implement Context as child type. |
| 1463 | + const context: ReactContext<mixed> = (newChild: any); |
| 1464 | + return reconcileChildFibersImpl( |
| 1465 | + returnFiber, |
| 1466 | + currentFirstChild, |
| 1467 | + readContextDuringReconcilation(returnFiber, context, lanes), |
| 1468 | + lanes, |
| 1469 | + ); |
1445 | 1470 | }
|
1446 | 1471 |
|
1447 | 1472 | throwOnInvalidObjectType(returnFiber, newChild);
|
|
0 commit comments