Fix incorrect type being passed to NativePerformance.mark (#47102)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/47102

Changelog: [internal]

In D64466057 / https://github.com/facebook/react-native/commit/32f7b3b4e0b8be1d1138f43c46b3c86d9a64c29a we accidentally modified the API of `NativePerformance.mark` (which we wanted to preserve and move the changes to `NativePerformance.markWithResult` after some iteration) to make `startTime` optional, which isn't compatible with the previous native API.

This fixes the issue by reverting the type back to being required and always passing it from the JS API.

Differential Revision: D64557467

fbshipit-source-id: 3ade4271622ac6213fd4c2d4948c7d40e4abe715
This commit is contained in:
Rubén Norte
2024-10-17 13:05:01 -07:00
committed by Facebook GitHub Bot
parent d11954e800
commit 14bbb87516
2 changed files with 5 additions and 3 deletions
@@ -116,13 +116,15 @@ export default class Performance {
markOptions?.startTime,
);
} else if (NativePerformance?.mark) {
NativePerformance.mark(markName, markOptions?.startTime);
computedStartTime = markOptions?.startTime ?? performance.now();
NativePerformance?.mark?.(markName, computedStartTime);
} else {
warnNoNativePerformance();
computedStartTime = performance.now();
}
return new PerformanceMark(markName, {
startTime: computedStartTime ?? performance.now(),
startTime: computedStartTime,
detail: markOptions?.detail,
});
}
@@ -46,7 +46,7 @@ export type PerformanceObserverInit = {
export interface Spec extends TurboModule {
+now?: () => number;
// TODO: remove when `markWithResult` is fully rolled out.
+mark?: (name: string, startTime?: number) => void;
+mark?: (name: string, startTime: number) => void;
// TODO: remove when `measureWithResult` is fully rolled out.
+measure?: (
name: string,