@@ -96,10 +96,7 @@ export default class ScrollableTabView extends React.Component {
9696 constructor ( props ) {
9797 super ( props ) ;
9898 this . state = {
99- checkedIndex : this . _getFirstIndex ( ) ,
100- refsObj : { } ,
101- lazyIndexs : this . _initLazyIndexs ( ) ,
102- isRefreshing : false
99+ ...this . _initialState ( )
103100 } ;
104101 this . sectionListScrollY = new Animated . Value ( 0 ) ;
105102 this . carouselScrollX = new Animated . Value ( 0 ) ;
@@ -134,6 +131,15 @@ export default class ScrollableTabView extends React.Component {
134131 this . _initial ( newProps , true ) ;
135132 }
136133
134+ _initialState ( ) {
135+ return {
136+ checkedIndex : this . _getFirstIndex ( ) ,
137+ refsObj : { } ,
138+ lazyIndexs : this . _initLazyIndexs ( ) ,
139+ isRefreshing : false
140+ } ;
141+ }
142+
137143 _initial ( props = this . props , isProcess = false ) {
138144 isProcess && this . _toProcess ( props ) ;
139145 this . tabs = this . _getTabs ( props ) ;
@@ -212,10 +218,7 @@ export default class ScrollableTabView extends React.Component {
212218 this . stacks = [ ] ;
213219 this . setState (
214220 {
215- checkedIndex : this . _getFirstIndex ( ) ,
216- refsObj : { } ,
217- lazyIndexs : this . _initLazyIndexs ( ) ,
218- isRefreshing : false
221+ ...this . _initialState ( )
219222 } ,
220223 ( ) => typeof callback === 'function' && callback ( )
221224 ) ;
@@ -570,26 +573,27 @@ export default class ScrollableTabView extends React.Component {
570573 } ;
571574
572575 render ( ) {
576+ const { style, title, onEndReachedThreshold, fixedHeader, tabsEnableAnimated, carouselProps, onScroll, sectionListProps } = this . props ;
573577 return (
574578 < View
575579 onLayout = { ( { nativeEvent } ) => {
576580 const { height } = nativeEvent . layout ;
577581 this . layoutHeight [ 'container' ] = height ;
578582 if ( height !== 0 ) this . _refresh ( ) ;
579583 } }
580- style = { [ styles . container , this . props . style ] }
584+ style = { [ styles . container , style ] }
581585 >
582- { ! ! this . props . title && this . _renderTitle ( ) }
586+ { ! ! title && this . _renderTitle ( ) }
583587 < SectionList
584588 ref = { rf => ( this . section = rf ) }
585589 keyExtractor = { ( item , index ) => `scrollable-tab-view-wrap-${ index } ` }
586590 renderSectionHeader = { this . _renderSectionHeader . bind ( this ) }
587591 onEndReached = { this . _onEndReached . bind ( this ) }
588- onEndReachedThreshold = { this . props . onEndReachedThreshold }
592+ onEndReachedThreshold = { onEndReachedThreshold }
589593 refreshControl = { < RefreshControl refreshing = { this . state . isRefreshing } onRefresh = { this . _onRefresh . bind ( this ) } /> }
590594 sections = { [ { data : [ 1 ] } ] }
591595 stickySectionHeadersEnabled = { true }
592- ListHeaderComponent = { ! this . props . fixedHeader && this . _renderHeader ( ) }
596+ ListHeaderComponent = { ! fixedHeader && this . _renderHeader ( ) }
593597 showsVerticalScrollIndicator = { false }
594598 showsHorizontalScrollIndicator = { false }
595599 renderItem = { ( ) => {
@@ -611,7 +615,7 @@ export default class ScrollableTabView extends React.Component {
611615 index
612616 } ) }
613617 onScroll = {
614- this . props . tabsEnableAnimated &&
618+ tabsEnableAnimated &&
615619 Animated . event (
616620 [
617621 {
@@ -625,29 +629,29 @@ export default class ScrollableTabView extends React.Component {
625629 }
626630 )
627631 }
628- { ...this . props . carouselProps }
632+ { ...carouselProps }
629633 />
630634 ) ;
631635 } }
632636 onScrollToIndexFailed = { ( ) => { } }
633637 onScroll = {
634- ! ! this . props . title
638+ ! ! title
635639 ? Animated . event (
636640 [
637641 {
638642 nativeEvent : { contentOffset : { y : this . sectionListScrollY } }
639643 }
640644 ] ,
641645 {
642- listener : ! ! this . props . onScroll && this . props . onScroll . bind ( this ) ,
646+ listener : ! ! onScroll && onScroll . bind ( this ) ,
643647 useNativeDriver : false
644648 }
645649 )
646- : ! ! this . props . onScroll
647- ? this . props . onScroll . bind ( this )
650+ : ! ! onScroll
651+ ? onScroll . bind ( this )
648652 : null
649653 }
650- { ...this . props . sectionListProps }
654+ { ...sectionListProps }
651655 > </ SectionList >
652656 </ View >
653657 ) ;
0 commit comments