@@ -106,9 +106,19 @@ export default class TabBarItem extends PureComponent {
106
106
onPress : _ . noop
107
107
} ;
108
108
109
- state = { } ;
110
- itemWidth = this . props . width ;
111
- itemRef = React . createRef ( ) ;
109
+ constructor ( props ) {
110
+ super ( props ) ;
111
+
112
+ this . itemWidth = this . props . width ;
113
+ this . state = { } ;
114
+ this . itemRef = React . createRef ( ) ;
115
+
116
+ if ( this . itemWidth ) {
117
+ const { index, onLayout} = this . props ;
118
+ onLayout ( { width : this . itemWidth } , index ) ;
119
+ }
120
+ }
121
+
112
122
113
123
onStateChange = event ( [
114
124
{
@@ -148,11 +158,11 @@ export default class TabBarItem extends PureComponent {
148
158
opacity
149
159
} ;
150
160
151
- // if (this.itemWidth ) {
152
- // style.flex = undefined;
153
- // style.width = this.itemWidth;
154
- // style.paddingHorizontal = undefined;
155
- // }
161
+ if ( this . props . width ) {
162
+ style . flex = undefined ;
163
+ style . width = this . itemWidth ;
164
+ style . paddingHorizontal = undefined ;
165
+ }
156
166
157
167
return style ;
158
168
}
@@ -234,7 +244,7 @@ export default class TabBarItem extends PureComponent {
234
244
onPress = { this . onPress }
235
245
testID = { testID }
236
246
>
237
- { icon && < Reanimated . Image source = { icon } style = { [ styles . tabItemIcon , this . getIconStyle ( ) ] } /> }
247
+ { icon && < Reanimated . Image source = { icon } style = { [ label && styles . tabItemIconWithLabel , this . getIconStyle ( ) ] } /> }
238
248
{ ! _ . isEmpty ( label ) && (
239
249
< Reanimated . Text style = { [ styles . tabItemLabel , this . getLabelStyle ( ) ] } >
240
250
{ uppercase ? _ . toUpper ( label ) : label }
@@ -257,7 +267,7 @@ const styles = StyleSheet.create({
257
267
tabItemLabel : {
258
268
...Typography . text80
259
269
} ,
260
- tabItemIcon : {
270
+ tabItemIconWithLabel : {
261
271
marginRight : 10
262
272
} ,
263
273
badge : {
0 commit comments