@@ -16,7 +16,6 @@ import {Colors, Spacings, Typography} from '../../style';
16
16
import FadedScrollView from '../fadedScrollView' ;
17
17
import { FaderProps } from '../fader' ;
18
18
import useScrollToItem from './useScrollToItem' ;
19
- import { orientations } from '../../commons/Constants' ;
20
19
import { useDidUpdate } from 'hooks' ;
21
20
22
21
const FIX_RTL = Constants . isRTL && Constants . isAndroid ;
@@ -164,7 +163,7 @@ const TabBar = (props: Props) => {
164
163
} = props ;
165
164
166
165
const tabBar = useRef < typeof FadedScrollView > ( ) ;
167
- const [ key , setKey ] = useState < orientations > ( Constants . orientation ) ;
166
+ const [ key , setKey ] = useState < string > ( generateKey ( Constants . orientation , labelColor , selectedLabelColor ) ) ;
168
167
const context = useContext ( TabBarContext ) ;
169
168
const { items : contextItems , currentPage, targetPage, containerWidth : contextContainerWidth } = context ;
170
169
const containerWidth : number = useMemo ( ( ) => {
@@ -286,10 +285,14 @@ const TabBar = (props: Props) => {
286
285
focusIndex ( currentPage . value ) ;
287
286
} else {
288
287
reset ( ) ;
289
- setKey ( Constants . orientation ) ;
288
+ setKey ( generateKey ( Constants . orientation , labelColor , selectedLabelColor ) ) ;
290
289
}
291
290
} , [ containerWidth ] ) ;
292
291
292
+ useDidUpdate ( ( ) => {
293
+ setKey ( generateKey ( Constants . orientation , labelColor , selectedLabelColor ) ) ;
294
+ } , [ labelColor , selectedLabelColor ] ) ;
295
+
293
296
return (
294
297
< View style = { _containerStyle } key = { key } bg-$backgroundElevated >
295
298
< FadedScrollView
@@ -365,4 +368,7 @@ const styles = StyleSheet.create({
365
368
}
366
369
} ) ;
367
370
371
+ const generateKey = ( orientation : string , labelColor = '' , selectedLabelColor = '' ) =>
372
+ `${ orientation } _${ labelColor } _${ selectedLabelColor } ` ;
373
+
368
374
export default asBaseComponent < TabControllerBarProps > ( forwardRef < Props > ( TabBar ) ) ;
0 commit comments