Skip to content

Commit 4d1ba2c

Browse files
committed
Fix/ interpolateColor with platformColors (#1979)
* Fix/ interpolateColor with platformColors * useRef for colors
1 parent 1481ca6 commit 4d1ba2c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/incubator/WheelPicker/Item.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback, useMemo, memo} from 'react';
1+
import React, {useCallback, useMemo, memo, useRef} from 'react';
22
import {TextStyle, StyleSheet} from 'react-native';
33
import Animated, {interpolateColor, useAnimatedStyle} from 'react-native-reanimated';
44
import Text, {TextProps} from '../../components/text';
@@ -7,14 +7,13 @@ import {Colors, Spacings} from '../../../src/style';
77
import {asBaseComponent} from '../../commons/new';
88
import {WheelPickerAlign} from './types';
99

10-
1110
const AnimatedTouchableOpacity = Animated.createAnimatedComponent(TouchableOpacity);
1211
const AnimatedText = Animated.createAnimatedComponent(Text);
1312

1413
export interface ItemProps {
1514
label: string;
1615
value: string | number;
17-
align?: WheelPickerAlign
16+
align?: WheelPickerAlign;
1817
}
1918

2019
interface InternalProps extends ItemProps {
@@ -50,11 +49,13 @@ const WheelPickerItem = memo(({
5049
}: InternalProps) => {
5150
const selectItem = useCallback(() => onSelect(index), [index]);
5251
const itemOffset = index * itemHeight;
52+
const _activeColor = useRef(activeColor.toString());
53+
const _inactiveColor = useRef(inactiveColor.toString());
5354

5455
const animatedColorStyle = useAnimatedStyle(() => {
5556
const color = interpolateColor(offset.value,
5657
[itemOffset - itemHeight, itemOffset, itemOffset + itemHeight],
57-
[inactiveColor, activeColor, inactiveColor]);
58+
[_inactiveColor.current, _activeColor.current, _inactiveColor.current]);
5859
return {color};
5960
}, [itemHeight]);
6061

0 commit comments

Comments
 (0)