mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
94995fdd9f
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
35 lines
916 B
JavaScript
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.'));
|
|
}
|