File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -111,9 +111,9 @@ class TabBarItem extends PureComponent<TabBarItemProps, State> {
111
111
styles = createStyles ( ) ;
112
112
layout : any = undefined ;
113
113
114
- UNSAFE_componentWillReceiveProps ( nextProps : TabBarItemProps ) {
115
- if ( this . props . selected !== nextProps . selected ) {
116
- this . animate ( nextProps . selected ) ;
114
+ componentDidUpdate ( prevProps : TabBarItemProps ) {
115
+ if ( prevProps . selected !== this . props . selected ) {
116
+ this . animate ( this . props . selected ) ;
117
117
}
118
118
}
119
119
Original file line number Diff line number Diff line change @@ -104,20 +104,19 @@ class TabBar extends Component<TabBarProps, State> {
104
104
itemsRefs : any [ ] = [ ] ;
105
105
scrollView ?: any = undefined ;
106
106
107
- UNSAFE_componentWillReceiveProps ( nextProps : TabBarProps ) {
107
+ componentDidUpdate ( prevProps : TabBarProps , prevState : State ) {
108
108
// TODO: since we're implementing an uncontrolled component here, we should verify the selectedIndex has changed
109
109
// between this.props and nextProps (basically the meaning of selectedIndex should be initialIndex)
110
+ const { selectedIndex} = this . props ;
110
111
const isIndexManuallyChanged =
111
- nextProps . selectedIndex !== this . state . currentIndex && this . props . selectedIndex !== nextProps . selectedIndex ;
112
- if ( isIndexManuallyChanged && nextProps . selectedIndex !== undefined ) {
113
- this . updateIndicator ( nextProps . selectedIndex ) ;
114
- }
115
- }
116
-
117
- componentDidUpdate ( prevProps : TabBarProps ) {
118
- const prevChildrenCount = React . Children . count ( prevProps . children ) ;
119
- if ( this . childrenCount < prevChildrenCount ) {
120
- this . updateIndicator ( 0 ) ;
112
+ selectedIndex !== prevState . currentIndex && prevProps . selectedIndex !== selectedIndex ;
113
+ if ( isIndexManuallyChanged && selectedIndex !== undefined ) {
114
+ this . updateIndicator ( selectedIndex ) ;
115
+ } else {
116
+ const prevChildrenCount = React . Children . count ( prevProps . children ) ;
117
+ if ( this . childrenCount < prevChildrenCount ) {
118
+ this . updateIndicator ( 0 ) ;
119
+ }
121
120
}
122
121
}
123
122
You can’t perform that action at this time.
0 commit comments