File tree Expand file tree Collapse file tree 3 files changed +51
-11
lines changed
packages/react-native-web/src/exports/ScrollView Expand file tree Collapse file tree 3 files changed +51
-11
lines changed Original file line number Diff line number Diff line change
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports [` components/ScrollView prop "refreshControl" with 1` ] = `
4
+ <div
5
+ id = " refresh-control"
6
+ >
7
+ <div
8
+ class = " css-view-1dbjc4n r-WebkitOverflowScrolling-150rngu r-flexDirection-eqz5dr r-flexGrow-16y2uox r-flexShrink-1wbh5a2 r-overflowX-11yh6sk r-overflowY-1rnoaur r-transform-1sncvnh"
9
+ style = " background-color: rgb(255, 0, 0);"
10
+ >
11
+ <div
12
+ class = " css-view-1dbjc4n"
13
+ />
14
+ </div >
15
+ </div >
16
+ ` ;
17
+
18
+ exports [` components/ScrollView prop "refreshControl" without 1` ] = `
19
+ <div
20
+ class = " css-view-1dbjc4n r-WebkitOverflowScrolling-150rngu r-flexDirection-eqz5dr r-flexGrow-16y2uox r-flexShrink-1wbh5a2 r-overflowX-11yh6sk r-overflowY-1rnoaur r-transform-1sncvnh"
21
+ style = " background-color: rgb(255, 0, 0);"
22
+ >
23
+ <div
24
+ class = " css-view-1dbjc4n"
25
+ />
26
+ </div >
27
+ ` ;
Original file line number Diff line number Diff line change @@ -86,4 +86,21 @@ describe('components/ScrollView', () => {
86
86
expect ( typeof node . scrollResponderScrollNativeHandleToKeyboard === 'function' ) . toBe ( true ) ;
87
87
} ) ;
88
88
} ) ;
89
+
90
+ describe ( 'prop "refreshControl"' , ( ) => {
91
+ test ( 'without' , ( ) => {
92
+ const { container } = render ( < ScrollView style = { { backgroundColor : 'red' } } /> ) ;
93
+ expect ( container . firstChild ) . toMatchSnapshot ( ) ;
94
+ } ) ;
95
+
96
+ test ( 'with' , ( ) => {
97
+ const { container } = render (
98
+ < ScrollView
99
+ refreshControl = { < div id = "refresh-control" /> }
100
+ style = { { backgroundColor : 'red' } }
101
+ />
102
+ ) ;
103
+ expect ( container . firstChild ) . toMatchSnapshot ( ) ;
104
+ } ) ;
105
+ } ) ;
89
106
} ) ;
Original file line number Diff line number Diff line change @@ -223,21 +223,17 @@ const ScrollView = ((createReactClass({
223
223
224
224
invariant ( ScrollViewClass !== undefined , 'ScrollViewClass must not be undefined' ) ;
225
225
226
- if ( refreshControl ) {
227
- return React . cloneElement (
228
- refreshControl ,
229
- { style : props . style } ,
230
- < ScrollViewClass { ...props } ref = { this . _setScrollNodeRef } style = { baseStyle } >
231
- { contentContainer }
232
- </ ScrollViewClass >
233
- ) ;
234
- }
235
-
236
- return (
226
+ const scrollView = (
237
227
< ScrollViewClass { ...props } ref = { this . _setScrollNodeRef } >
238
228
{ contentContainer }
239
229
</ ScrollViewClass >
240
230
) ;
231
+
232
+ if ( refreshControl ) {
233
+ return React . cloneElement ( refreshControl , { style : props . style } , scrollView ) ;
234
+ }
235
+
236
+ return scrollView ;
241
237
} ,
242
238
243
239
_handleContentOnLayout ( e : Object ) {
You can’t perform that action at this time.
0 commit comments