Skip to content

Commit ed85b64

Browse files
committed
refactor: move Image tintColor and resizeMode from style to props
React Native deprecates the style-form of these properties on Image: "Image: style.resizeMode is deprecated. Please use props.resizeMode." "Image: style.tintColor is deprecated. Please use props.tintColor." - Icon (image source variant): tintColor / resizeMode lifted out of the style array onto the <Image> props. - AppbarBackIcon (iOS back chevron): same migration; drop the now-empty styles.icon entry. Snapshot in Appbar.test.tsx updated to reflect the new prop placement.
1 parent 3257eca commit ed85b64

3 files changed

Lines changed: 11 additions & 19 deletions

File tree

src/components/Appbar/AppbarBackIcon.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,9 @@ const AppbarBackIcon = ({ size, color }: { size: number; color: string }) => {
1919
>
2020
<Image
2121
source={require('../../assets/back-chevron.png')}
22-
style={[
23-
styles.icon,
24-
{ tintColor: color, width: iosIconSize, height: iosIconSize },
25-
]}
22+
tintColor={color}
23+
resizeMode="contain"
24+
style={{ width: iosIconSize, height: iosIconSize }}
2625
accessibilityIgnoresInvertColors
2726
/>
2827
</View>
@@ -41,9 +40,6 @@ const styles = StyleSheet.create({
4140
alignItems: 'center',
4241
justifyContent: 'center',
4342
},
44-
icon: {
45-
resizeMode: 'contain',
46-
},
4743
});
4844

4945
export default AppbarBackIcon;

src/components/Icon.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ const Icon = ({
130130
{...rest}
131131
testID={testID}
132132
source={s}
133+
tintColor={color}
134+
resizeMode="contain"
133135
style={[
134136
{
135137
transform: [{ scaleX: direction === 'rtl' ? -1 : 1 }],
136138
},
137139
{
138140
width: size,
139141
height: size,
140-
tintColor: color,
141-
resizeMode: `contain`,
142142
},
143143
]}
144144
{...accessibilityProps}

src/components/__tests__/Appbar/__snapshots__/Appbar.test.tsx.snap

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -625,23 +625,19 @@ exports[`Appbar passes additional props to AppbarBackAction, AppbarContent and A
625625
>
626626
<Image
627627
accessibilityIgnoresInvertColors={true}
628+
resizeMode="contain"
628629
source={
629630
{
630631
"testUri": "../../../src/assets/back-chevron.png",
631632
}
632633
}
633634
style={
634-
[
635-
{
636-
"resizeMode": "contain",
637-
},
638-
{
639-
"height": 21,
640-
"tintColor": "rgba(29, 27, 32, 1)",
641-
"width": 21,
642-
},
643-
]
635+
{
636+
"height": 21,
637+
"width": 21,
638+
}
644639
}
640+
tintColor="rgba(29, 27, 32, 1)"
645641
/>
646642
</View>
647643
</View>

0 commit comments

Comments
 (0)