Files
react-native/Libraries/Core/setUpPerformance.js
T
Ruslan Shestopalyuk 059184e7ce setUpPerformance not to redirect to WebPerformance before the API is public (#35901)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35901

[Changelog][Internal]
Partially reverts the change that was redirecting `performance` instance to the new implementation in WebPerformance, until the actual implementation becomes public and native modules are included by default.

Reviewed By: rubennorte

Differential Revision: D42607379

fbshipit-source-id: c1ce995d20b9dfe7aef8436cea00d89b81e32932
2023-01-19 10:08:32 -08:00

25 lines
623 B
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict
* @format
*/
if (!global.performance) {
global.performance = ({}: {now?: () => number});
}
/**
* Returns a double, measured in milliseconds.
* https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
*/
if (typeof global.performance.now !== 'function') {
global.performance.now = function () {
const performanceNow = global.nativePerformanceNow || Date.now;
return performanceNow();
};
}