diff --git a/Libraries/Performance/NativeJSCSamplingProfiler.js b/Libraries/Performance/NativeJSCSamplingProfiler.js new file mode 100644 index 0000000000..9ac1fad140 --- /dev/null +++ b/Libraries/Performance/NativeJSCSamplingProfiler.js @@ -0,0 +1,20 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow + * @format + */ + +'use strict'; + +import type {TurboModule} from 'RCTExport'; +import * as TurboModuleRegistry from 'TurboModuleRegistry'; + +export interface Spec extends TurboModule { + +operationComplete: (token: number, result: ?string, error: ?string) => void; +} + +export default TurboModuleRegistry.get('JSCSamplingProfiler'); diff --git a/Libraries/Performance/SamplingProfiler.js b/Libraries/Performance/SamplingProfiler.js index cce9cb9596..2808f83ebd 100644 --- a/Libraries/Performance/SamplingProfiler.js +++ b/Libraries/Performance/SamplingProfiler.js @@ -28,8 +28,11 @@ const SamplingProfiler = { error = e.toString(); } - const {JSCSamplingProfiler} = require('../BatchedBridge/NativeModules'); - JSCSamplingProfiler.operationComplete(token, result, error); + const NativeJSCSamplingProfiler = require('./NativeJSCSamplingProfiler') + .default; + if (NativeJSCSamplingProfiler) { + NativeJSCSamplingProfiler.operationComplete(token, result, error); + } }, };