Skip to content

Commit 27d951f

Browse files
WazzeZtum-more
andauthored
fix ViewShotProperties.style type (#473)
Co-authored-by: Nattapong Saengphrom <[email protected]>
1 parent b8bd53f commit 27d951f

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

src/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
declare module 'react-native-view-shot' {
1212
import { Component, ReactInstance, RefObject, ReactNode } from 'react'
13-
import { ViewStyle } from 'react-native'
13+
import { StyleProp, ViewStyle } from 'react-native'
1414
import { LayoutChangeEvent } from 'react-native'
1515

1616

@@ -94,9 +94,9 @@ declare module 'react-native-view-shot' {
9494
*/
9595
onLayout?(event: LayoutChangeEvent): void;
9696
/**
97-
* style prop as ViewStyle
97+
* style prop as StyleProp<ViewStyle>
9898
*/
99-
style?: ViewStyle;
99+
style?: StyleProp<ViewStyle>;
100100
}
101101

102102
export default class ViewShot extends Component<React.PropsWithChildren<ViewShotProperties>> {

src/index.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @flow
22
import React, { Component } from "react";
3-
import { View, Platform, findNodeHandle } from "react-native";
3+
import { View, Platform, findNodeHandle, StyleProp } from "react-native";
44
import RNViewShot from "./RNViewShot";
55
import type { ViewStyleProp } from "react-native/Libraries/StyleSheet/StyleSheet";
66
import type { LayoutEvent } from "react-native/Libraries/Types/CoreEventTypes";
@@ -14,7 +14,7 @@ type Options = {
1414
quality: number,
1515
result: "tmpfile" | "base64" | "data-uri" | "zip-base64",
1616
snapshotContentContainer: boolean,
17-
handleGLSurfaceViewOnAndroid: boolean
17+
handleGLSurfaceViewOnAndroid: boolean,
1818
};
1919

2020
if (!RNViewShot) {
@@ -36,16 +36,17 @@ const defaultOptions = {
3636
quality: 1,
3737
result: "tmpfile",
3838
snapshotContentContainer: false,
39-
handleGLSurfaceViewOnAndroid: false
39+
handleGLSurfaceViewOnAndroid: false,
4040
};
4141

4242
// validate and coerce options
43-
function validateOptions(
44-
input: ?$Shape<Options>
45-
): { options: Options, errors: Array<string> } {
43+
function validateOptions(input: ?$Shape<Options>): {
44+
options: Options,
45+
errors: Array<string>,
46+
} {
4647
const options: Options = {
4748
...defaultOptions,
48-
...input
49+
...input,
4950
};
5051
const errors = [];
5152
if (
@@ -136,7 +137,7 @@ export function captureRef<T: React$ElementType>(
136137
if (__DEV__ && errors.length > 0) {
137138
console.warn(
138139
"react-native-view-shot: bad options:\n" +
139-
errors.map(e => `- ${e}`).join("\n")
140+
errors.map((e) => `- ${e}`).join("\n")
140141
);
141142
}
142143
return RNViewShot.captureRef(view, options);
@@ -158,7 +159,7 @@ export function captureScreen(optionsObject?: Options): Promise<string> {
158159
if (__DEV__ && errors.length > 0) {
159160
console.warn(
160161
"react-native-view-shot: bad options:\n" +
161-
errors.map(e => `- ${e}`).join("\n")
162+
errors.map((e) => `- ${e}`).join("\n")
162163
);
163164
}
164165
return RNViewShot.captureScreen(options);
@@ -171,7 +172,7 @@ type Props = {
171172
onLayout?: (e: *) => void,
172173
onCapture?: (uri: string) => void,
173174
onCaptureFailure?: (e: Error) => void,
174-
style?: ViewStyleProp
175+
style?: StyleProp<ViewStyleProp>,
175176
};
176177

177178
function checkCompatibleProps(props: Props) {
@@ -204,7 +205,7 @@ export default class ViewShot extends Component<Props> {
204205
lastCapturedURI: ?string;
205206

206207
resolveFirstLayout: (layout: Object) => void;
207-
firstLayoutPromise: Promise<Object> = new Promise(resolve => {
208+
firstLayoutPromise: Promise<Object> = new Promise((resolve) => {
208209
this.resolveFirstLayout = resolve;
209210
});
210211

0 commit comments

Comments
 (0)