Skip to content

Commit 4b0c22f

Browse files
authored
bug fixes for TabBar refactor (#1106)
* bug fixes for TabBar refactor * generating types * Change type to JSX.ElementClass * ScrollBarScreen to .tsx * reverting to object as type * ScrollBar - type fix; TabBar removing containerView wrapper
1 parent 74ab7ea commit 4b0c22f

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

demo/src/screens/componentScreens/ScrollBarScreen.js renamed to demo/src/screens/componentScreens/ScrollBarScreen.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, {Component} from 'react';
22
import {View, Text, ScrollBar, Button} from 'react-native-ui-lib';
3+
4+
35
class ScrollBarScreen extends Component {
46
state = {
57
selectedIndex: 0

generatedTypes/components/scrollBar/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface ScrollBarProps extends FlatListProps<any> {
99
/**
1010
* The element to use as a container, instead of a View
1111
*/
12-
containerView?: JSX.Element;
12+
containerView?: React.ComponentClass;
1313
/**
1414
* The props to pass the container
1515
*/

src/components/scrollBar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface ScrollBarProps extends FlatListProps<any> {
2525
/**
2626
* The element to use as a container, instead of a View
2727
*/
28-
containerView?: JSX.Element,
28+
containerView?: React.ComponentClass,
2929
/**
3030
* The props to pass the container
3131
*/

src/components/tabBar/index.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ class TabBar extends Component<TabBarProps, State> {
7676
static displayName = 'TabBar';
7777

7878
static defaultProps: Partial<TabBarProps> = {
79-
selectedIndex: 0,
80-
backgroundColor: DEFAULT_BACKGROUND_COLOR
79+
selectedIndex: 0
8180
};
8281

8382
static Item = TabBarItem;
@@ -189,7 +188,7 @@ class TabBar extends Component<TabBarProps, State> {
189188
};
190189

191190
onContentSizeChange = (width: number) => {
192-
if (this.scrollContentWidth && this.scrollContentWidth !== width) {
191+
if (this.scrollContentWidth !== width) {
193192
this.scrollContentWidth = width;
194193
const {minTabsForScroll} = this.props;
195194
const minChildrenCount = minTabsForScroll || MIN_TABS_FOR_SCROLL;
@@ -200,7 +199,7 @@ class TabBar extends Component<TabBarProps, State> {
200199
};
201200

202201
renderTabBar() {
203-
const {height, backgroundColor, containerView, containerProps, gradientMargins} = this.props;
202+
const {height, backgroundColor = DEFAULT_BACKGROUND_COLOR, containerView, containerProps, gradientMargins} = this.props;
204203
const {scrollEnabled} = this.state;
205204
const containerHeight = height || DEFAULT_HEIGHT;
206205

@@ -264,14 +263,12 @@ class TabBar extends Component<TabBarProps, State> {
264263
}
265264

266265
render() {
267-
const {enableShadow, style, containerView, containerWidth, backgroundColor} = this.props;
268-
const Container = containerView ? containerView : View;
266+
const {enableShadow, style, backgroundColor = DEFAULT_BACKGROUND_COLOR} = this.props;
269267

270268
return (
271269
// @ts-ignore
272-
<Container
270+
<View
273271
useSafeArea
274-
fullWidth={containerWidth ? false : undefined}
275272
style={[
276273
styles.container,
277274
enableShadow && styles.containerShadow,
@@ -284,7 +281,7 @@ class TabBar extends Component<TabBarProps, State> {
284281
]}
285282
>
286283
{this.renderTabBar()}
287-
</Container>
284+
</View>
288285
);
289286
}
290287
}

0 commit comments

Comments
 (0)