Skip to content

Commit 5b8b66b

Browse files
committed
foo
1 parent b857251 commit 5b8b66b

File tree

10 files changed

+97
-1
lines changed

10 files changed

+97
-1
lines changed

packages/react-art/src/ReactARTHostConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,7 @@ export function preparePortalMount(portalInstance: any): void {
451451
export function detachDeletedInstance(node: Instance): void {
452452
// noop
453453
}
454+
455+
export function requestPostPaintCallback(callback: (time: number) => void) {
456+
// noop
457+
}

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,10 @@ export const cancelTimeout: any =
377377
typeof clearTimeout === 'function' ? clearTimeout : (undefined: any);
378378
export const noTimeout = -1;
379379
const localPromise = typeof Promise === 'function' ? Promise : undefined;
380-
380+
const localRequestAnimationFrame =
381+
typeof requestAnimationFrame === 'function'
382+
? requestAnimationFrame
383+
: scheduleTimeout;
381384
// -------------------
382385
// Microtasks
383386
// -------------------
@@ -1379,3 +1382,9 @@ export function setupIntersectionObserver(
13791382
},
13801383
};
13811384
}
1385+
1386+
export function requestPostPaintCallback(callback: (time: number) => void) {
1387+
localRequestAnimationFrame(() => {
1388+
localRequestAnimationFrame(time => callback(time));
1389+
});
1390+
}

packages/react-native-renderer/src/ReactFabricHostConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,7 @@ export function preparePortalMount(portalInstance: Instance): void {
609609
export function detachDeletedInstance(node: Instance): void {
610610
// noop
611611
}
612+
613+
export function requestPostPaintCallback(callback: (time: number) => void) {
614+
// noop
615+
}

packages/react-native-renderer/src/ReactNativeHostConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,3 +510,7 @@ export function preparePortalMount(portalInstance: Instance): void {
510510
export function detachDeletedInstance(node: Instance): void {
511511
// noop
512512
}
513+
514+
export function requestPostPaintCallback(callback: (time: number) => void) {
515+
// noop
516+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,11 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
473473
logRecoverableError() {
474474
// no-op
475475
},
476+
477+
requestPostPaintCallback(callback) {
478+
const endTime = Scheduler.unstable_now();
479+
callback(endTime);
480+
},
476481
};
477482

478483
const hostConfig = useMutation

packages/react-reconciler/src/ReactFiberHostConfigWithNoMutation.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ export const hideTextInstance = shim;
3535
export const unhideInstance = shim;
3636
export const unhideTextInstance = shim;
3737
export const clearContainer = shim;
38+
export const requestPostPaintCallback = shim;

packages/react-reconciler/src/__tests__/ReactFiberHostContext-test.internal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ describe('ReactFiberHostContext', () => {
6767
return DefaultEventPriority;
6868
},
6969
supportsMutation: true,
70+
requestPostPaintCallback: function() {},
7071
});
7172

7273
const container = Renderer.createContainer(
@@ -129,6 +130,7 @@ describe('ReactFiberHostContext', () => {
129130
getCurrentEventPriority: function() {
130131
return DefaultEventPriority;
131132
},
133+
requestPostPaintCallback: function() {},
132134
supportsMutation: true,
133135
});
134136

packages/react-reconciler/src/__tests__/ReactTransitionTracing-test.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,4 +2273,66 @@ describe('ReactInteractionTracing', () => {
22732273
});
22742274
expect(Scheduler).toHaveYielded(['Hidden Text']);
22752275
});
2276+
2277+
// @gate enableTransitionTracing
2278+
it('discrete events', async () => {
2279+
const transitionCallbacks = {
2280+
onTransitionStart: (name, startTime) => {
2281+
Scheduler.unstable_yieldValue(
2282+
`onTransitionStart(${name}, ${startTime})`,
2283+
);
2284+
},
2285+
onTransitionProgress: (name, startTime, endTime, pending) => {
2286+
const suspenseNames = pending.map(p => p.name || '<null>').join(', ');
2287+
Scheduler.unstable_yieldValue(
2288+
`onTransitionProgress(${name}, ${startTime}, ${endTime}, [${suspenseNames}])`,
2289+
);
2290+
},
2291+
onTransitionComplete: (name, startTime, endTime) => {
2292+
Scheduler.unstable_yieldValue(
2293+
`onTransitionComplete(${name}, ${startTime}, ${endTime})`,
2294+
);
2295+
},
2296+
};
2297+
2298+
function App() {
2299+
return (
2300+
<Suspense
2301+
fallback={<Text text="Loading..." />}
2302+
unstable_name="suspense page">
2303+
<AsyncText text="Page Two" />
2304+
</Suspense>
2305+
);
2306+
}
2307+
2308+
const root = ReactNoop.createRoot({
2309+
unstable_transitionCallbacks: transitionCallbacks,
2310+
});
2311+
2312+
await act(async () => {
2313+
ReactNoop.discreteUpdates(() =>
2314+
startTransition(() => root.render(<App />), {name: 'page transition'}),
2315+
);
2316+
ReactNoop.expire(1000);
2317+
await advanceTimers(1000);
2318+
});
2319+
2320+
expect(Scheduler).toHaveYielded([
2321+
'Suspend [Page Two]',
2322+
'Loading...',
2323+
'onTransitionStart(page transition, 0)',
2324+
'onTransitionProgress(page transition, 0, 1000, [suspense page])',
2325+
]);
2326+
await act(async () => {
2327+
ReactNoop.discreteUpdates(() => resolveText('Page Two'));
2328+
ReactNoop.expire(1000);
2329+
await advanceTimers(1000);
2330+
});
2331+
2332+
expect(Scheduler).toHaveYielded([
2333+
'Page Two',
2334+
'onTransitionProgress(page transition, 0, 2000, [])',
2335+
'onTransitionComplete(page transition, 0, 2000)',
2336+
]);
2337+
});
22762338
});

packages/react-reconciler/src/forks/ReactFiberHostConfig.custom.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const prepareScopeUpdate = $$$hostConfig.prepareScopeUpdate;
6767
export const getInstanceFromScope = $$$hostConfig.getInstanceFromScope;
6868
export const getCurrentEventPriority = $$$hostConfig.getCurrentEventPriority;
6969
export const detachDeletedInstance = $$$hostConfig.detachDeletedInstance;
70+
export const requestPostPaintCallback = $$$hostConfig.requestPostPaintCallback;
7071

7172
// -------------------
7273
// Microtasks

packages/react-test-renderer/src/ReactTestHostConfig.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,7 @@ export function detachDeletedInstance(node: Instance): void {
317317
export function logRecoverableError(error: mixed): void {
318318
// noop
319319
}
320+
321+
export function requestPostPaintCallback(callback: (time: number) => void) {
322+
// noop
323+
}

0 commit comments

Comments
 (0)