@@ -15,72 +15,24 @@ const NativeModules = require('NativeModules');
15
15
const Platform = require ( 'Platform' ) ;
16
16
17
17
const defineLazyObjectProperty = require ( 'defineLazyObjectProperty' ) ;
18
- const findNodeHandle = require ( 'findNodeHandle' ) ;
19
18
const invariant = require ( 'fbjs/lib/invariant' ) ;
20
19
21
- import type React from 'react' ;
22
-
23
20
const { UIManager } = NativeModules ;
24
21
25
22
invariant ( UIManager , 'UIManager is undefined. The native module config is probably incorrect.' ) ;
26
23
27
- const _takeSnapshot = UIManager . takeSnapshot ;
28
-
29
- // findNodeHandle() returns a reference to a wrapper component with viewConfig.
30
- // This wrapper is required for NativeMethodsMixin.setNativeProps, but most
31
- // callers want the native tag (number) and not the wrapper. For this purpose,
32
- // the ReactNative renderer decorates findNodeHandle() and extracts the tag.
33
- // However UIManager can't require ReactNative without introducing a cycle, and
34
- // deferring the require causes a significant performance regression in Wilde
35
- // (along the lines of 17% regression in RN Bridge startup). So as a temporary
36
- // workaround, this wrapper method mimics what the native renderer does.
37
- // TODO (bvaughn) Remove this and use findNodeHandle directly once stack is gone
38
- function findNodeHandleWrapper ( componentOrHandle : any ) : ?number {
39
- const instance : any = findNodeHandle ( componentOrHandle ) ;
40
-
41
- if ( instance ) {
42
- return typeof instance . _nativeTag === 'number'
43
- ? instance . _nativeTag
44
- : instance . getHostNode ( ) ;
45
- } else {
46
- return null ;
47
- }
48
- }
49
-
50
- /**
51
- * Capture an image of the screen, window or an individual view. The image
52
- * will be stored in a temporary file that will only exist for as long as the
53
- * app is running.
54
- *
55
- * The `view` argument can be the literal string `window` if you want to
56
- * capture the entire window, or it can be a reference to a specific
57
- * React Native component.
58
- *
59
- * The `options` argument may include:
60
- * - width/height (number) - the width and height of the image to capture.
61
- * - format (string) - either 'png' or 'jpeg'. Defaults to 'png'.
62
- * - quality (number) - the quality when using jpeg. 0.0 - 1.0 (default).
63
- *
64
- * Returns a Promise.
65
- * @platform ios
66
- */
67
- UIManager . takeSnapshot = async function (
68
- view ?: 'window' | React . Element < any > | number ,
69
- options ?: {
70
- width ?: number ,
71
- height ?: number ,
72
- format ?: 'png' | 'jpeg' ,
73
- quality ?: number ,
74
- } ,
75
- ) {
76
- if ( ! _takeSnapshot ) {
77
- console . warn ( 'UIManager.takeSnapshot is not available on this platform' ) ;
78
- return ;
79
- }
80
- if ( typeof view !== 'number' && view !== 'window' ) {
81
- view = findNodeHandleWrapper ( view ) || 'window' ;
82
- }
83
- return _takeSnapshot ( view , options ) ;
24
+ // In past versions of ReactNative users called UIManager.takeSnapshot()
25
+ // However takeSnapshot was moved to ReactNative in order to support flat
26
+ // bundles and to avoid a cyclic dependency between UIManager and ReactNative.
27
+ // UIManager.takeSnapshot still exists though. In order to avoid confusion or
28
+ // accidental usage, mask the method with a deprecation warning.
29
+ UIManager . __takeSnapshot = UIManager . takeSnapshot ;
30
+ UIManager . takeSnapshot = function ( ) {
31
+ invariant (
32
+ false ,
33
+ 'UIManager.takeSnapshot should not be called directly. ' +
34
+ 'Use ReactNative.takeSnapshot instead.'
35
+ ) ;
84
36
} ;
85
37
86
38
/**
0 commit comments