暫無描述

index.js 683B

123456789101112131415161718192021222324252627
  1. //@flow
  2. import { NativeModules, findNodeHandle } from "react-native";
  3. const { RNViewShot } = NativeModules;
  4. export function takeSnapshot(
  5. view: number | ReactElement<any>,
  6. options ?: {
  7. width ?: number;
  8. height ?: number;
  9. filename ?: string;
  10. format ?: "png" | "jpg" | "jpeg" | "webm";
  11. quality ?: number;
  12. result ?: "file" | "base64" | "data-uri";
  13. }
  14. ): Promise<string> {
  15. if (typeof view !== "number") {
  16. const node = findNodeHandle(view);
  17. if (!node) return Promise.reject(new Error("findNodeHandle failed to resolve view="+String(view)));
  18. view = node;
  19. }
  20. return RNViewShot.takeSnapshot(view, options);
  21. }
  22. export default { takeSnapshot };