Files
react-native/packages/rn-tester/NativeModuleExample/NativeScreenshotManager.js
T
Vitali Zaidman 94995fdd9f add rules to prefer Error objects to be thrown and rejected (#54229)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54229

Changelog: [General][Added] Added eslint rule to warn when a non-error is being thrown from a function or rejected for a promise.

Reviewed By: huntie

Differential Revision: D85237916

fbshipit-source-id: e0e4fbc6b4620a19be1959d3953856c7e44ad4e0
2025-10-23 06:42:55 -07:00

35 lines
916 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(new Error('ScreenshotManager is not defined.'));
}