File tree Expand file tree Collapse file tree 3 files changed +55
-89
lines changed Expand file tree Collapse file tree 3 files changed +55
-89
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,12 @@ export function SafeAreaProvider({
5353 height : Dimensions . get ( 'window' ) . height ,
5454 } ,
5555 ) ;
56- const onInsetsChange = React . useCallback (
57- ( event : InsetChangedEvent ) => {
58- const {
59- nativeEvent : { frame : nextFrame , insets : nextInsets } ,
60- } = event ;
56+ const onInsetsChange = React . useCallback ( ( event : InsetChangedEvent ) => {
57+ const {
58+ nativeEvent : { frame : nextFrame , insets : nextInsets } ,
59+ } = event ;
6160
61+ setFrame ( ( frame ) => {
6262 if (
6363 // Backwards compat with old native code that won't send frame.
6464 nextFrame &&
@@ -67,25 +67,30 @@ export function SafeAreaProvider({
6767 nextFrame . x !== frame . x ||
6868 nextFrame . y !== frame . y )
6969 ) {
70- setFrame ( nextFrame ) ;
70+ return nextFrame ;
71+ } else {
72+ return frame ;
7173 }
74+ } ) ;
7275
76+ setInsets ( ( insets ) => {
7377 if (
7478 ! insets ||
7579 nextInsets . bottom !== insets . bottom ||
7680 nextInsets . left !== insets . left ||
7781 nextInsets . right !== insets . right ||
7882 nextInsets . top !== insets . top
7983 ) {
80- setInsets ( nextInsets ) ;
84+ return nextInsets ;
85+ } else {
86+ return insets ;
8187 }
82- } ,
83- [ frame , insets ] ,
84- ) ;
88+ } ) ;
89+ } , [ ] ) ;
8590
8691 return (
8792 < NativeSafeAreaProvider
88- style = { [ styles . fill , style ] }
93+ style = { StyleSheet . compose ( styles . fill , style ) }
8994 onInsetsChange = { onInsetsChange }
9095 { ...others }
9196 >
Original file line number Diff line number Diff line change @@ -4,12 +4,9 @@ exports[`SafeAreaContext does not render child until inset values are received 1
44<RNCSafeAreaProvider
55 onInsetsChange = { [Function ]}
66 style = {
7- [
8- {
9- " flex" : 1 ,
10- },
11- undefined ,
12- ]
7+ {
8+ " flex" : 1 ,
9+ }
1310 }
1411/>
1512` ;
@@ -18,12 +15,9 @@ exports[`SafeAreaContext renders 1`] = `
1815<RNCSafeAreaProvider
1916 onInsetsChange = { [Function ]}
2017 style = {
21- [
22- {
23- " flex" : 1 ,
24- },
25- undefined ,
26- ]
18+ {
19+ " flex" : 1 ,
20+ }
2721 }
2822/>
2923` ;
@@ -32,12 +26,9 @@ exports[`SafeAreaContext renders child when inset values are received 1`] = `
3226<RNCSafeAreaProvider
3327 onInsetsChange = { [Function ]}
3428 style = {
35- [
36- {
37- " flex" : 1 ,
38- },
39- undefined ,
40- ]
29+ {
30+ " flex" : 1 ,
31+ }
4132 }
4233/>
4334` ;
@@ -46,12 +37,9 @@ exports[`SafeAreaContext renders child when inset values are received 2`] = `
4637<RNCSafeAreaProvider
4738 onInsetsChange = { [Function ]}
4839 style = {
49- [
50- {
51- " flex" : 1 ,
52- },
53- undefined ,
54- ]
40+ {
41+ " flex" : 1 ,
42+ }
5543 }
5644>
5745 <View
@@ -75,12 +63,9 @@ exports[`SafeAreaContext supports setting initial insets 1`] = `
7563<RNCSafeAreaProvider
7664 onInsetsChange = { [Function ]}
7765 style = {
78- [
79- {
80- " flex" : 1 ,
81- },
82- undefined ,
83- ]
66+ {
67+ " flex" : 1 ,
68+ }
8469 }
8570>
8671 <View
@@ -104,23 +89,17 @@ exports[`SafeAreaContext uses inner insets 1`] = `
10489<RNCSafeAreaProvider
10590 onInsetsChange = { [Function ]}
10691 style = {
107- [
108- {
109- " flex" : 1 ,
110- },
111- undefined ,
112- ]
92+ {
93+ " flex" : 1 ,
94+ }
11395 }
11496>
11597 <RNCSafeAreaProvider
11698 onInsetsChange = { [Function ]}
11799 style = {
118- [
119- {
120- " flex" : 1 ,
121- },
122- undefined ,
123- ]
100+ {
101+ " flex" : 1 ,
102+ }
124103 }
125104 >
126105 <View
@@ -145,23 +124,17 @@ exports[`SafeAreaContext uses parent insets when available 1`] = `
145124<RNCSafeAreaProvider
146125 onInsetsChange = { [Function ]}
147126 style = {
148- [
149- {
150- " flex" : 1 ,
151- },
152- undefined ,
153- ]
127+ {
128+ " flex" : 1 ,
129+ }
154130 }
155131>
156132 <RNCSafeAreaProvider
157133 onInsetsChange = { [Function ]}
158134 style = {
159- [
160- {
161- " flex" : 1 ,
162- },
163- undefined ,
164- ]
135+ {
136+ " flex" : 1 ,
137+ }
165138 }
166139 >
167140 <View
Original file line number Diff line number Diff line change @@ -4,12 +4,9 @@ exports[`SafeAreaView can override padding styles 1`] = `
44<RNCSafeAreaProvider
55 onInsetsChange = { [Function ]}
66 style = {
7- [
8- {
9- " flex" : 1 ,
10- },
11- undefined ,
12- ]
7+ {
8+ " flex" : 1 ,
9+ }
1310 }
1411>
1512 <RNCSafeAreaView
@@ -36,12 +33,9 @@ exports[`SafeAreaView can set edges 1`] = `
3633<RNCSafeAreaProvider
3734 onInsetsChange = { [Function ]}
3835 style = {
39- [
40- {
41- " flex" : 1 ,
42- },
43- undefined ,
44- ]
36+ {
37+ " flex" : 1 ,
38+ }
4539 }
4640>
4741 <RNCSafeAreaView
@@ -63,12 +57,9 @@ exports[`SafeAreaView can set edges value type 1`] = `
6357<RNCSafeAreaProvider
6458 onInsetsChange = { [Function ]}
6559 style = {
66- [
67- {
68- " flex" : 1 ,
69- },
70- undefined ,
71- ]
60+ {
61+ " flex" : 1 ,
62+ }
7263 }
7364>
7465 <RNCSafeAreaView
@@ -96,12 +87,9 @@ exports[`SafeAreaView renders 1`] = `
9687<RNCSafeAreaProvider
9788 onInsetsChange = { [Function ]}
9889 style = {
99- [
100- {
101- " flex" : 1 ,
102- },
103- undefined ,
104- ]
90+ {
91+ " flex" : 1 ,
92+ }
10593 }
10694>
10795 <RNCSafeAreaView
You can’t perform that action at this time.
0 commit comments