@@ -25,6 +25,9 @@ type Config = {
25
25
initialLayout ?: { width ?: number ; height ?: number } ;
26
26
lazy ?: boolean ;
27
27
lazyPlaceholderComponent ?: React . ComponentType < { route : Route } > ;
28
+ pagerComponent ?: React . ComponentType <
29
+ Parameters < React . ComponentProps < typeof TabView > [ 'renderPager' ] > [ 0 ]
30
+ > ;
28
31
tabBarComponent ?: React . ComponentType < any > ;
29
32
tabBarOptions ?: MaterialTabBarOptions ;
30
33
tabBarPosition ?: 'top' | 'bottom' ;
@@ -42,17 +45,7 @@ type Props = NavigationViewProps &
42
45
} ;
43
46
44
47
class MaterialTabView extends React . PureComponent < Props > {
45
- _renderLazyPlaceholder = ( props : { route : Route } ) => {
46
- const { lazyPlaceholderComponent : LazyPlaceholder } = this . props ;
47
-
48
- if ( LazyPlaceholder != null ) {
49
- return < LazyPlaceholder { ...props } /> ;
50
- }
51
-
52
- return null ;
53
- } ;
54
-
55
- _renderTabBar = ( props : SceneRendererProps ) => {
48
+ private renderTabBar = ( props : SceneRendererProps ) => {
56
49
const { state } = this . props . navigation ;
57
50
const route = state . routes [ state . index ] ;
58
51
const { descriptors } = this . props ;
@@ -107,10 +100,11 @@ class MaterialTabView extends React.PureComponent<Props> {
107
100
onTabPress,
108
101
onTabLongPress,
109
102
screenProps,
110
- lazyPlaceholderComponent,
111
103
tabBarComponent,
112
104
tabBarOptions,
113
105
/* eslint-enable @typescript-eslint/no-unused-vars */
106
+ lazyPlaceholderComponent,
107
+ pagerComponent,
114
108
navigation,
115
109
descriptors,
116
110
...rest
@@ -137,8 +131,17 @@ class MaterialTabView extends React.PureComponent<Props> {
137
131
{ ...rest }
138
132
navigationState = { navigation . state }
139
133
swipeEnabled = { swipeEnabled }
140
- renderTabBar = { this . _renderTabBar }
141
- renderLazyPlaceholder = { this . _renderLazyPlaceholder }
134
+ renderTabBar = { this . renderTabBar }
135
+ renderLazyPlaceholder = {
136
+ lazyPlaceholderComponent !== undefined
137
+ ? props => React . createElement ( lazyPlaceholderComponent , props )
138
+ : undefined
139
+ }
140
+ renderPager = {
141
+ pagerComponent !== undefined
142
+ ? props => React . createElement ( pagerComponent , props )
143
+ : undefined
144
+ }
142
145
/>
143
146
) ;
144
147
}
0 commit comments