Skip to content

Commit 7fad8e2

Browse files
committed
creating ref after react 17
1 parent a7f46de commit 7fad8e2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ const ScrollableTabView = createReactClass({
115115
};
116116
},
117117

118+
componentWillMount() {
119+
this.scrollView = React.createRef();
120+
},
121+
118122
componentDidUpdate(prevProps) {
119123
if (this.props.children !== prevProps.children) {
120124
this.updateSceneKeys({ page: this.state.currentPage, children: this.props.children, });
@@ -232,7 +236,7 @@ const ScrollableTabView = createReactClass({
232236
pagingEnabled
233237
automaticallyAdjustContentInsets={false}
234238
contentOffset={{ x: this.props.initialPage * this.state.containerWidth, }}
235-
ref={(scrollView) => { this.scrollView = scrollView; }}
239+
ref={this.scrollView}
236240
onScroll={Animated.event(
237241
[{ nativeEvent: { contentOffset: { x: this.state.scrollXIOS, }, }, }, ],
238242
{ useNativeDriver: true, listener: this._onScroll, }
@@ -271,7 +275,7 @@ const ScrollableTabView = createReactClass({
271275
listener: this._onScroll,
272276
},
273277
)}
274-
ref={(scrollView) => { this.scrollView = scrollView; }}
278+
ref={this.scrollView}
275279
{...this.props.contentProps}
276280
>
277281
{scenes}

0 commit comments

Comments
 (0)