Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)
, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); Enables Basic View Transition support for React Native Fabric rendere… · react/react@6a04c36 · GitHub
Skip to content

Commit 6a04c36

Browse files
authored
Enables Basic View Transition support for React Native Fabric renderer (#35764)
## Summary Enables Basic View Transition support for React Native Fabric renderer. **Implemented:** - Added FabricUIManager bindings for view transition methods: `applyViewTransitionName`, `startViewTransition` - Implemented `startViewTransition` with proper callback orchestration (mutation → layout → afterMutation → spawnedWork → passive) - Added fallback behavior that flushes work synchronously when Fabric's `startViewTransition` returns null (e.g., when the ViewTransition ReactNativeFeatureFlag is not enabled) - Added Flow type declarations for new FabricUIManager methods - Stubbed with `__DEV__` warnings for all the other view transition config functions that are not yet implemented This allows React Native apps using Fabric to leverage the View Transition API for coordinated animations during state transitions, with graceful degradation when the native side doesn't support it. Below are diagrams of proposed architecture in fabric, and observation of what/when config functions get called during a basic shared transition example <img width="2290" height="1529" alt="Untitled-2026-03-19-1240" src="https://github.com/user-attachments/assets/192c9169-bc25-449c-a33b-dfec67179e7f" /> ## How did you test this change? - [x] `yarn flow fabric` - Flow type checks pass - [x] `yarn lint` - Lint checks pass - [x] Manually tested in Android catalyst app with `enableViewTransition` and `enableViewTransitionForPersistenceMode `in `ReactFeatureFlags.test-renderer.native-fb.js` and View Transition enabled via ReactNativeFeatureFlag - [x] Verified in the minified `ReactFabric-dev.fb.js` that the 'shim' config functions are not included - [x] Verified fallback behavior logs warning in `__DEV__` and flushes work synchronously when ViewTransition flag isn't enabled in Fabric
1 parent d594643 commit 6a04c36

16 files changed

Lines changed: 422 additions & 24 deletions

‎packages/react-native-renderer/src/ReactFiberConfigFabric.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ export * from 'react-reconciler/src/ReactFiberConfigWithNoScopes';
166166
export*from'react-reconciler/src/ReactFiberConfigWithNoTestSelectors';
167167
export*from'react-reconciler/src/ReactFiberConfigWithNoResources';
168168
export*from'react-reconciler/src/ReactFiberConfigWithNoSingletons';
169+
export*from'./ReactFiberConfigFabricWithViewTransition';
169170

170171
exportfunctionappendInitialChild(
171172
parentInstance: Instance,
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
*/
9+
10+
importtype{TransitionTypes}from'react/src/ReactTransitionType';
11+
importtype{
12+
Instance,
13+
Props,
14+
Container,
15+
SuspendedState,
16+
GestureTimeline,
17+
}from'./ReactFiberConfigFabric';
18+
19+
const{
20+
applyViewTransitionName: fabricApplyViewTransitionName,
21+
startViewTransition: fabricStartViewTransition,
22+
}=nativeFabricUIManager;
23+
24+
exporttypeInstanceMeasurement={
25+
rect: {x: number,y: number,width: number,height: number},
26+
abs: boolean,
27+
clip: boolean,
28+
view: boolean,
29+
};
30+
31+
exporttypeRunningViewTransition={
32+
finished: Promise<void>,
33+
ready: Promise<void>,
34+
...
35+
};
36+
37+
interfaceViewTransitionPseudoElementTypeextendsmixin$Animatable{
38+
_pseudo: string;
39+
_name: string;
40+
}
41+
42+
functionViewTransitionPseudoElement(
43+
this: ViewTransitionPseudoElementType,
44+
pseudo: string,
45+
name: string,
46+
){
47+
// TODO: Get the owner document from the root container.
48+
this._pseudo=pseudo;
49+
this._name=name;
50+
}
51+
52+
exporttypeViewTransitionInstance=null|{
53+
name: string,
54+
old: mixin$Animatable,
55+
new: mixin$Animatable,
56+
...
57+
};
58+
59+
exportfunctionrestoreViewTransitionName(
60+
instance: Instance,
61+
props: Props,
62+
): void{
63+
if(__DEV__){
64+
console.warn('restoreViewTransitionName is not implemented');
65+
}
66+
}
67+
68+
// Cancel the old and new snapshots of viewTransitionName
69+
exportfunctioncancelViewTransitionName(
70+
instance: Instance,
71+
oldName: string,
72+
props: Props,
73+
): void{
74+
if(__DEV__){
75+
console.warn('cancelViewTransitionName is not implemented');
76+
}
77+
}
78+
79+
exportfunctioncancelRootViewTransitionName(rootContainer: Container): void{
80+
// No-op
81+
}
82+
83+
exportfunctionrestoreRootViewTransitionName(rootContainer: Container): void{
84+
// No-op
85+
}
86+
87+
exportfunctioncloneRootViewTransitionContainer(
88+
rootContainer: Container,
89+
): Instance{
90+
if(__DEV__){
91+
console.warn('cloneRootViewTransitionContainer is not implemented');
92+
}
93+
// $FlowFixMe[incompatible-return] Return empty stub
94+
returnnull;
95+
}
96+
97+
exportfunctionremoveRootViewTransitionClone(
98+
rootContainer: Container,
99+
clone: Instance,
100+
): void{
101+
if(__DEV__){
102+
console.warn('removeRootViewTransitionClone is not implemented');
103+
}
104+
}
105+
106+
exportfunctionmeasureInstance(instance: Instance): InstanceMeasurement{
107+
if(__DEV__){
108+
console.warn('measureInstance is not implemented');
109+
}
110+
return{
111+
rect: {
112+
x: 0,
113+
y: 0,
114+
width: 0,
115+
height: 0,
116+
},
117+
abs: false,
118+
clip: false,
119+
// TODO: properly calculate whether instance is in viewport
120+
view: true,
121+
};
122+
}
123+
124+
exportfunctionmeasureClonedInstance(instance: Instance): InstanceMeasurement{
125+
if(__DEV__){
126+
console.warn('measureClonedInstance is not implemented');
127+
}
128+
return{
129+
rect: {x: 0,y: 0,width: 0,height: 0},
130+
abs: false,
131+
clip: false,
132+
view: true,
133+
};
134+
}
135+
136+
exportfunctionwasInstanceInViewport(
137+
measurement: InstanceMeasurement,
138+
): boolean{
139+
returnmeasurement.view;
140+
}
141+
142+
exportfunctionhasInstanceChanged(
143+
oldMeasurement: InstanceMeasurement,
144+
newMeasurement: InstanceMeasurement,
145+
): boolean{
146+
if(__DEV__){
147+
console.warn('hasInstanceChanged is not implemented');
148+
}
149+
returnfalse;
150+
}
151+
152+
exportfunctionhasInstanceAffectedParent(
153+
oldMeasurement: InstanceMeasurement,
154+
newMeasurement: InstanceMeasurement,
155+
): boolean{
156+
if(__DEV__){
157+
console.warn('hasInstanceAffectedParent is not implemented');
158+
}
159+
returnfalse;
160+
}
161+
162+
exportfunctionstartGestureTransition(
163+
suspendedState: null|SuspendedState,
164+
rootContainer: Container,
165+
timeline: GestureTimeline,
166+
rangeStart: number,
167+
rangeEnd: number,
168+
transitionTypes: null|TransitionTypes,
169+
mutationCallback: ()=>void,
170+
animateCallback: ()=>void,
171+
errorCallback: (error: mixed)=>void,
172+
finishedAnimation: ()=>void,
173+
): RunningViewTransition{
174+
if(__DEV__){
175+
console.warn('startGestureTransition is not implemented');
176+
}
177+
return{
178+
finished: Promise.resolve(),
179+
ready: Promise.resolve(),
180+
};
181+
}
182+
183+
exportfunctionstopViewTransition(transition: RunningViewTransition): void{
184+
if(__DEV__){
185+
console.warn('stopViewTransition is not implemented');
186+
}
187+
}
188+
189+
exportfunctionaddViewTransitionFinishedListener(
190+
transition: RunningViewTransition,
191+
callback: ()=>void,
192+
): void{
193+
transition.finished.finally(callback);
194+
}
195+
196+
exportfunctioncreateViewTransitionInstance(
197+
name: string,
198+
): ViewTransitionInstance{
199+
return{
200+
name,
201+
old: new(ViewTransitionPseudoElement: any)('old',name),
202+
new: new(ViewTransitionPseudoElement: any)('new',name),
203+
};
204+
}
205+
206+
exportfunctionapplyViewTransitionName(
207+
instance: Instance,
208+
name: string,
209+
className: ?string,
210+
): void{
211+
// add view-transition-name to things that might animate for browser
212+
fabricApplyViewTransitionName(instance.node,name,className);
213+
}
214+
215+
exportfunctionstartViewTransition(
216+
suspendedState: null|SuspendedState,
217+
rootContainer: Container,
218+
transitionTypes: null|TransitionTypes,
219+
mutationCallback: ()=>void,
220+
layoutCallback: ()=>void,
221+
afterMutationCallback: ()=>void,
222+
spawnedWorkCallback: ()=>void,
223+
passiveCallback: ()=>mixed,
224+
errorCallback: (error: mixed)=>void,
225+
blockedCallback: (name: string)=>void,
226+
finishedAnimation: ()=>void,
227+
): null|RunningViewTransition{
228+
const transition =fabricStartViewTransition(
229+
// mutation
230+
()=>{
231+
mutationCallback();// completeRoot should run here
232+
layoutCallback();
233+
afterMutationCallback();
234+
},
235+
);
236+
237+
if(transition==null){
238+
if(__DEV__){
239+
console.warn(
240+
"startViewTransition didn't kick off transition in Fabric, the ViewTransition ReactNativeFeatureFlag might not be enabled.",
241+
);
242+
}
243+
// Flush remaining work synchronously.
244+
mutationCallback();
245+
layoutCallback();
246+
// Skip afterMutationCallback(). We don't need it since we're not animating.
247+
spawnedWorkCallback();
248+
// Skip passiveCallback(). Spawned work will schedule a task.
249+
returnnull;
250+
}
251+
252+
transition.ready.then(()=>{
253+
spawnedWorkCallback();
254+
});
255+
256+
transition.finished.finally(()=>{
257+
passiveCallback();
258+
});
259+
260+
returntransition;
261+
}

‎packages/react-noop-renderer/src/createReactNoop.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import type {EventPriority} from 'react-reconciler/src/ReactEventPriorities';
2525
importtype{TransitionTypes}from'react/src/ReactTransitionType';
2626
importtypeof*asHostConfigfrom'react-reconciler/src/ReactFiberConfig';
2727
importtypeof*asReactFiberConfigWithNoMutationfrom'react-reconciler/src/ReactFiberConfigWithNoMutation';
28+
importtypeof*asReactFiberConfigWithNoViewTransitionfrom'react-reconciler/src/ReactFiberConfigWithNoViewTransition';
2829
importtypeof*asReactFiberConfigWithNoPersistencefrom'react-reconciler/src/ReactFiberConfigWithNoPersistence';
2930

3031
importtypeof*asReconcilerAPIfrom'react-reconciler/src/ReactFiberReconciler';
@@ -709,7 +710,8 @@ function createReactNoop(
709710

710711
constmutationHostConfig: Pick<
711712
HostConfig,
712-
$Keys<ReactFiberConfigWithNoMutation>,
713+
|$Keys<ReactFiberConfigWithNoMutation>
714+
|$Keys<ReactFiberConfigWithNoViewTransition>,
713715
>={
714716
supportsMutation: true,
715717

0 commit comments

Comments
 (0)