Files
react-native/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js
Dawid Małecki 7959a63a1a Migrate rn-tester codegen types imports to use root exported CodegenTypes namespace (#50976)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50976

This is the second part of the migration of `rn-tester` package to use root imports. In this diff the `CodegenTypes` namespace is used to define Codegen primitives.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D73780584

fbshipit-source-id: c13c2dfcfa4d023978a9463af1d2a3bf7b72476c
2025-04-29 06:06:16 -07:00

35 lines
870 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-local
* @format
*/
import type {CodegenTypes, TurboModule} from 'react-native';
import {TurboModuleRegistry} from 'react-native';
export type ScreenshotManagerOptions = CodegenTypes.UnsafeObject;
export interface Spec extends TurboModule {
+getConstants: () => {};
takeScreenshot(
id: string,
options: ScreenshotManagerOptions,
): Promise<string>;
}
const NativeModule = TurboModuleRegistry.get<Spec>('ScreenshotManager');
export function takeScreenshot(
id: string,
options: ScreenshotManagerOptions,
): Promise<string> {
if (NativeModule != null) {
return NativeModule.takeScreenshot(id, options);
}
return Promise.reject();
}