Skip to content

Commit 645b85e

Browse files
authored
Fix - first item selection is not being updated (#908)
* Fix - first item selection is not being updated * securing the passed index * checking undefined
1 parent bf9e2b3 commit 645b85e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/components/tabBar/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class TabBar extends Component<TabBarProps, State> {
104104
// between this.props and nextProps (basically the meaning of selectedIndex should be initialIndex)
105105
const isIndexManuallyChanged =
106106
nextProps.selectedIndex !== this.state.currentIndex && this.props.selectedIndex !== nextProps.selectedIndex;
107-
if (isIndexManuallyChanged) {
107+
if (isIndexManuallyChanged && nextProps.selectedIndex !== undefined) {
108108
this.updateIndicator(nextProps.selectedIndex);
109109
}
110110
}
@@ -125,13 +125,11 @@ class TabBar extends Component<TabBarProps, State> {
125125
return _.get(child, 'props.ignore');
126126
}
127127

128-
updateIndicator(index?: number) {
129-
if (index) {
130-
if (!this.isIgnored(index)) {
131-
this.setState({currentIndex: index}, () => {
132-
this.scrollToSelected();
133-
});
134-
}
128+
updateIndicator(index: number) {
129+
if (!this.isIgnored(index)) {
130+
this.setState({currentIndex: index}, () => {
131+
this.scrollToSelected();
132+
});
135133
}
136134
}
137135

0 commit comments

Comments
 (0)