forked from gre/react-native-view-shot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
26 lines (22 loc) · 683 Bytes
/
index.js
File metadata and controls
26 lines (22 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//@flow
import { NativeModules, findNodeHandle } from "react-native";
const { RNViewShot } = NativeModules;
export function takeSnapshot(
view: number | ReactElement<any>,
options ?: {
width ?: number;
height ?: number;
filename ?: string;
format ?: "png" | "jpg" | "jpeg" | "webm";
quality ?: number;
result ?: "file" | "base64" | "data-uri";
}
): Promise<string> {
if (typeof view !== "number") {
const node = findNodeHandle(view);
if (!node) return Promise.reject(new Error("findNodeHandle failed to resolve view="+String(view)));
view = node;
}
return RNViewShot.takeSnapshot(view, options);
}
export default { takeSnapshot };