@@ -17,6 +17,7 @@ import type {
17
17
Container ,
18
18
TextInstance ,
19
19
Instance ,
20
+ ActivityInstance ,
20
21
SuspenseInstance ,
21
22
Props ,
22
23
HoistableRoot ,
@@ -30,9 +31,10 @@ import {
30
31
HostText ,
31
32
HostRoot ,
32
33
SuspenseComponent ,
34
+ ActivityComponent ,
33
35
} from 'react-reconciler/src/ReactWorkTags' ;
34
36
35
- import { getParentSuspenseInstance } from './ReactFiberConfigDOM' ;
37
+ import { getParentHydrationBoundary } from './ReactFiberConfigDOM' ;
36
38
37
39
import { enableScopeAPI } from 'shared/ReactFeatureFlags' ;
38
40
@@ -59,7 +61,12 @@ export function detachDeletedInstance(node: Instance): void {
59
61
60
62
export function precacheFiberNode (
61
63
hostInst : Fiber ,
62
- node : Instance | TextInstance | SuspenseInstance | ReactScopeInstance ,
64
+ node :
65
+ | Instance
66
+ | TextInstance
67
+ | SuspenseInstance
68
+ | ActivityInstance
69
+ | ReactScopeInstance ,
63
70
) : void {
64
71
( node : any ) [ internalInstanceKey ] = hostInst ;
65
72
}
@@ -81,15 +88,16 @@ export function isContainerMarkedAsRoot(node: Container): boolean {
81
88
82
89
// Given a DOM node, return the closest HostComponent or HostText fiber ancestor.
83
90
// If the target node is part of a hydrated or not yet rendered subtree, then
84
- // this may also return a SuspenseComponent or HostRoot to indicate that.
91
+ // this may also return a SuspenseComponent, ActivityComponent or HostRoot to
92
+ // indicate that.
85
93
// Conceptually the HostRoot fiber is a child of the Container node. So if you
86
94
// pass the Container node as the targetNode, you will not actually get the
87
95
// HostRoot back. To get to the HostRoot, you need to pass a child of it.
88
- // The same thing applies to Suspense boundaries.
96
+ // The same thing applies to Suspense and Activity boundaries.
89
97
export function getClosestInstanceFromNode ( targetNode : Node ) : null | Fiber {
90
98
let targetInst = ( targetNode : any ) [ internalInstanceKey ] ;
91
99
if ( targetInst ) {
92
- // Don't return HostRoot or SuspenseComponent here.
100
+ // Don't return HostRoot, SuspenseComponent or ActivityComponent here.
93
101
return targetInst ;
94
102
}
95
103
// If the direct event target isn't a React owned DOM node, we need to look
@@ -129,8 +137,8 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
129
137
) {
130
138
// Next we need to figure out if the node that skipped past is
131
139
// nested within a dehydrated boundary and if so, which one.
132
- let suspenseInstance = getParentSuspenseInstance ( targetNode ) ;
133
- while ( suspenseInstance !== null ) {
140
+ let hydrationInstance = getParentHydrationBoundary ( targetNode ) ;
141
+ while ( hydrationInstance !== null ) {
134
142
// We found a suspense instance. That means that we haven't
135
143
// hydrated it yet. Even though we leave the comments in the
136
144
// DOM after hydrating, and there are boundaries in the DOM
@@ -140,15 +148,15 @@ export function getClosestInstanceFromNode(targetNode: Node): null | Fiber {
140
148
// Let's get the fiber associated with the SuspenseComponent
141
149
// as the deepest instance.
142
150
// $FlowFixMe[prop-missing]
143
- const targetSuspenseInst = suspenseInstance [ internalInstanceKey ] ;
144
- if ( targetSuspenseInst ) {
145
- return targetSuspenseInst ;
151
+ const targetFiber = hydrationInstance [ internalInstanceKey ] ;
152
+ if ( targetFiber ) {
153
+ return targetFiber ;
146
154
}
147
155
// If we don't find a Fiber on the comment, it might be because
148
156
// we haven't gotten to hydrate it yet. There might still be a
149
157
// parent boundary that hasn't above this one so we need to find
150
158
// the outer most that is known.
151
- suspenseInstance = getParentSuspenseInstance ( suspenseInstance ) ;
159
+ hydrationInstance = getParentHydrationBoundary ( hydrationInstance ) ;
152
160
// If we don't find one, then that should mean that the parent
153
161
// host component also hasn't hydrated yet. We can return it
154
162
// below since it will bail out on the isMounted check later.
@@ -176,6 +184,7 @@ export function getInstanceFromNode(node: Node): Fiber | null {
176
184
tag === HostComponent ||
177
185
tag === HostText ||
178
186
tag === SuspenseComponent ||
187
+ tag === ActivityComponent ||
179
188
tag === HostHoistable ||
180
189
tag === HostSingleton ||
181
190
tag === HostRoot
@@ -211,15 +220,17 @@ export function getNodeFromInstance(inst: Fiber): Instance | TextInstance {
211
220
}
212
221
213
222
export function getFiberCurrentPropsFromNode (
214
- node : Container | Instance | TextInstance | SuspenseInstance ,
223
+ node :
224
+ | Container
225
+ | Instance
226
+ | TextInstance
227
+ | SuspenseInstance
228
+ | ActivityInstance ,
215
229
) : Props {
216
230
return ( node : any ) [ internalPropsKey ] || null ;
217
231
}
218
232
219
- export function updateFiberProps (
220
- node : Instance | TextInstance | SuspenseInstance ,
221
- props : Props ,
222
- ) : void {
233
+ export function updateFiberProps ( node : Instance , props : Props ) : void {
223
234
( node : any ) [ internalPropsKey ] = props ;
224
235
}
225
236
0 commit comments