@@ -24,25 +24,47 @@ export interface ViewPropTypes extends ViewProps, ContainerModifiers {
24
24
* TODO: probobly isn't needed
25
25
*/
26
26
height ?: string | number ;
27
+ /**
28
+ * Experimental: Pass time in ms to delay render
29
+ */
30
+ renderDelay ?: number ;
27
31
}
28
32
type PropsTypes = BaseComponentInjectedProps & ForwardRefInjectedProps & ViewPropTypes ;
29
33
34
+ interface ViewState {
35
+ ready : boolean ;
36
+ }
37
+
30
38
/**
31
39
* @description : An enhanced View component
32
40
* @extends : View
33
41
* @extendslink : https://facebook.github.io/react-native/docs/view.html
34
42
* @modifiers : margins, paddings, alignments, background, borderRadius
35
43
*/
36
- class View extends PureComponent < PropsTypes > {
44
+ class View extends PureComponent < PropsTypes , ViewState > {
37
45
static displayName = 'View' ;
38
46
private Container : React . ClassType < any , any , any > ;
47
+
39
48
constructor ( props : PropsTypes ) {
40
49
super ( props ) ;
41
50
42
51
this . Container = props . useSafeArea && Constants . isIOS ? SafeAreaView : RNView ;
43
52
if ( props . animated ) {
44
53
this . Container = Animated . createAnimatedComponent ( this . Container ) ;
45
54
}
55
+
56
+ this . state = {
57
+ ready : ! props . renderDelay
58
+ } ;
59
+ }
60
+
61
+ componentDidMount ( ) {
62
+ const { renderDelay} = this . props ;
63
+ if ( renderDelay ) {
64
+ setTimeout ( ( ) => {
65
+ this . setState ( { ready : true } ) ;
66
+ } , renderDelay ) ;
67
+ }
46
68
}
47
69
48
70
// TODO: do we need this?
@@ -52,6 +74,10 @@ class View extends PureComponent<PropsTypes> {
52
74
}
53
75
54
76
render ( ) {
77
+ if ( ! this . state . ready ) {
78
+ return null ;
79
+ }
80
+
55
81
// (!) extract left, top, bottom... props to avoid passing them on Android
56
82
// eslint-disable-next-line
57
83
const {
0 commit comments