@@ -3,6 +3,10 @@ import React, { Component } from "react";
33import { View , NativeModules , Platform , findNodeHandle } from "react-native" ;
44const { RNViewShot } = NativeModules ;
55
6+ import type { Element , ElementRef } from 'react' ;
7+ import type { ViewStyleProp } from 'StyleSheet' ;
8+ import type { LayoutEvent } from 'CoreEventTypes' ;
9+
610const neverEndingPromise = new Promise ( ( ) => { } ) ;
711
812type Options = {
@@ -85,7 +89,7 @@ function validateOptions(
8589}
8690
8791export function captureRef (
88- view : number | ReactElement < * > ,
92+ view : number | ? View ,
8993 optionsObject ?: Object
9094) : Promise < string > {
9195 if ( typeof view !== "number" ) {
@@ -132,10 +136,11 @@ export function captureScreen(
132136type Props = {
133137 options ?: Object ,
134138 captureMode ?: "mount" | "continuous" | "update" ,
135- children : React . Element < * > ,
139+ children : Element < * > ,
136140 onLayout ?: ( e : * ) => void ,
137141 onCapture ?: ( uri : string ) => void ,
138- onCaptureFailure ?: ( e : Error ) => void
142+ onCaptureFailure ?: ( e : Error ) => void ,
143+ style ?: ViewStyleProp
139144} ;
140145
141146function checkCompatibleProps ( props : Props ) {
@@ -160,17 +165,16 @@ function checkCompatibleProps(props: Props) {
160165 }
161166}
162167
163- export default class ViewShot extends Component {
168+ export default class ViewShot extends Component < Props > {
164169 static captureRef = captureRef ;
165170 static releaseCapture = releaseCapture ;
166- props : Props ;
167171 root : ?View ;
168172
169173 _raf : * ;
170174 lastCapturedURI : ?string ;
171175
172176 resolveFirstLayout : ( layout : Object ) => void ;
173- firstLayoutPromise = new Promise ( resolve => {
177+ firstLayoutPromise = new Promise < void > ( resolve => {
174178 this . resolveFirstLayout = resolve ;
175179 } ) ;
176180
@@ -223,11 +227,11 @@ export default class ViewShot extends Component {
223227 }
224228 } ;
225229
226- onRef = ( ref : View ) => {
230+ onRef = ( ref : ElementRef < * > ) => {
227231 this. root = ref ;
228232 } ;
229233
230- onLayout = ( e : { nativeEvent : { layout : Object } } ) => {
234+ onLayout = ( e : LayoutEvent ) => {
231235 const { onLayout } = this . props ;
232236 this . resolveFirstLayout ( e . nativeEvent . layout ) ;
233237 if ( onLayout ) onLayout ( e ) ;
0 commit comments