@@ -108,8 +108,8 @@ interface Props extends TabControllerItemProps {
108
108
export default function TabBarItem ( {
109
109
index,
110
110
label,
111
- labelColor,
112
- selectedLabelColor,
111
+ labelColor = DEFAULT_LABEL_COLOR ,
112
+ selectedLabelColor = DEFAULT_SELECTED_LABEL_COLOR ,
113
113
labelStyle,
114
114
selectedLabelStyle,
115
115
icon,
@@ -131,6 +131,11 @@ export default function TabBarItem({
131
131
const sharedLabelStyle = useSharedValue ( JSON . parse ( JSON . stringify ( labelStyle ) ) ) ;
132
132
const sharedSelectedLabelStyle = useSharedValue ( JSON . parse ( JSON . stringify ( selectedLabelStyle ) ) ) ;
133
133
134
+ // NOTE: We clone these color values in refs because they might contain a PlatformColor value
135
+ // which throws an error (see https://github.com/software-mansion/react-native-reanimated/issues/3164)
136
+ const inactiveColor = useRef ( _ . cloneDeep ( labelColor ) ) ;
137
+ const activeColor = useRef ( _ . cloneDeep ( ! ignore ? selectedLabelColor : inactiveColor . current ) ) ;
138
+
134
139
useEffect ( ( ) => {
135
140
if ( props . width ) {
136
141
props . onLayout ?.( { nativeEvent : { layout : { x : 0 , y : 0 , width : itemWidth . current , height : 0 } } } as LayoutChangeEvent ,
@@ -165,21 +170,15 @@ export default function TabBarItem({
165
170
166
171
const animatedLabelColorStyle = useAnimatedStyle ( ( ) => {
167
172
const isActive = currentPage . value === index ;
168
- const inactiveColor = labelColor || DEFAULT_LABEL_COLOR ;
169
- const activeColor = ! ignore ? selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR : inactiveColor ;
170
-
171
173
return {
172
- color : isActive ? activeColor : inactiveColor
174
+ color : isActive ? activeColor . current : inactiveColor . current
173
175
} ;
174
176
} ) ;
175
177
176
178
const animatedIconStyle = useAnimatedStyle ( ( ) => {
177
179
const isActive = currentPage . value === index ;
178
- const inactiveColor = labelColor || DEFAULT_LABEL_COLOR ;
179
- const activeColor = ! ignore ? selectedLabelColor || DEFAULT_SELECTED_LABEL_COLOR : inactiveColor ;
180
-
181
180
return {
182
- tintColor : isActive ? activeColor : inactiveColor
181
+ tintColor : isActive ? activeColor . current : inactiveColor . current
183
182
} ;
184
183
} ) ;
185
184
0 commit comments