@@ -32,6 +32,7 @@ type Thenable = {
32
32
type Container = {
33
33
rootID : string ,
34
34
children : Array < Instance | TextInstance > ,
35
+ pendingChildren : Array < Instance | TextInstance > ,
35
36
} ;
36
37
type Props = { prop : any , hidden : boolean , children ?: mixed } ;
37
38
type Instance = { |
@@ -457,7 +458,9 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
457
458
finalizeContainerChildren (
458
459
container : Container ,
459
460
newChildren : Array < Instance | TextInstance > ,
460
- ) : void { } ,
461
+ ) : void {
462
+ container. pendingChildren = newChildren ;
463
+ } ,
461
464
462
465
replaceContainerChildren (
463
466
container : Container ,
@@ -581,13 +584,22 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
581
584
}
582
585
} ,
583
586
587
+ getPendingChildren ( rootID : string = DEFAULT_ROOT_ID ) {
588
+ const container = rootContainers . get ( rootID ) ;
589
+ if ( container ) {
590
+ return container . pendingChildren ;
591
+ } else {
592
+ return null ;
593
+ }
594
+ } ,
595
+
584
596
getOrCreateRootContainer (
585
597
rootID : string = DEFAULT_ROOT_ID ,
586
598
isConcurrent : boolean = false ,
587
599
) {
588
600
let root = roots . get ( rootID ) ;
589
601
if ( ! root ) {
590
- const container = { rootID : rootID , children : [ ] } ;
602
+ const container = { rootID : rootID , pendingChildren : [ ] , children : [ ] } ;
591
603
rootContainers . set ( rootID , container ) ;
592
604
root = NoopRenderer . createContainer ( container , isConcurrent , false ) ;
593
605
roots . set ( rootID , root ) ;
@@ -614,6 +626,25 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
614
626
return children ;
615
627
} ,
616
628
629
+ getPendingChildrenAsJSX ( rootID : string = DEFAULT_ROOT_ID ) {
630
+ const children = childToJSX ( ReactNoop . getPendingChildren ( rootID ) , null ) ;
631
+ if ( children === null ) {
632
+ return null ;
633
+ }
634
+ if ( Array . isArray ( children ) ) {
635
+ return {
636
+ $$typeof : REACT_ELEMENT_TYPE ,
637
+ type : REACT_FRAGMENT_TYPE ,
638
+ key : null ,
639
+ ref : null ,
640
+ props : { children} ,
641
+ _owner : null ,
642
+ _store : __DEV__ ? { } : undefined ,
643
+ } ;
644
+ }
645
+ return children ;
646
+ } ,
647
+
617
648
createPortal (
618
649
children : ReactNodeList ,
619
650
container : Container ,
@@ -778,7 +809,7 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
778
809
// Trick to flush passive effects without exposing an internal API:
779
810
// Create a throwaway root and schedule a dummy update on it.
780
811
const rootID = 'bloopandthenmoreletterstoavoidaconflict' ;
781
- const container = { rootID : rootID , children : [ ] } ;
812
+ const container = { rootID : rootID , pendingChildren : [ ] , children : [ ] } ;
782
813
rootContainers . set ( rootID , container ) ;
783
814
const root = NoopRenderer . createContainer ( container , true , false ) ;
784
815
NoopRenderer . updateContainer ( null , root , null , null ) ;
0 commit comments