1
- import React , { useCallback , useMemo , memo } from 'react' ;
1
+ import React , { useCallback , useMemo , memo , useRef } from 'react' ;
2
2
import { TextStyle , StyleSheet } from 'react-native' ;
3
3
import Animated , { interpolateColor , useAnimatedStyle } from 'react-native-reanimated' ;
4
4
import Text , { TextProps } from '../../components/text' ;
@@ -7,14 +7,13 @@ import {Colors, Spacings} from '../../../src/style';
7
7
import { asBaseComponent } from '../../commons/new' ;
8
8
import { WheelPickerAlign } from './types' ;
9
9
10
-
11
10
const AnimatedTouchableOpacity = Animated . createAnimatedComponent ( TouchableOpacity ) ;
12
11
const AnimatedText = Animated . createAnimatedComponent ( Text ) ;
13
12
14
13
export interface ItemProps {
15
14
label : string ;
16
15
value : string | number ;
17
- align ?: WheelPickerAlign
16
+ align ?: WheelPickerAlign ;
18
17
}
19
18
20
19
interface InternalProps extends ItemProps {
@@ -50,11 +49,13 @@ const WheelPickerItem = memo(({
50
49
} : InternalProps ) => {
51
50
const selectItem = useCallback ( ( ) => onSelect ( index ) , [ index ] ) ;
52
51
const itemOffset = index * itemHeight ;
52
+ const _activeColor = useRef ( activeColor . toString ( ) ) ;
53
+ const _inactiveColor = useRef ( inactiveColor . toString ( ) ) ;
53
54
54
55
const animatedColorStyle = useAnimatedStyle ( ( ) => {
55
56
const color = interpolateColor ( offset . value ,
56
57
[ itemOffset - itemHeight , itemOffset , itemOffset + itemHeight ] ,
57
- [ inactiveColor , activeColor , inactiveColor ] ) ;
58
+ [ _inactiveColor . current , _activeColor . current , _inactiveColor . current ] ) ;
58
59
return { color} ;
59
60
} , [ itemHeight ] ) ;
60
61
0 commit comments