Commit 665212e
Fix Android Image
Summary:
Fixes #49075
The Image `defaultSource` prop is causing a runtime error from 0.77 just by using it in the Image component (see error in the linked issue). This might be a regression from some changes in the prop processing logic from either #47710, #47713 or #47754.
[ANDROID] [FIXED] - Fix Image defaultSource runtime error
Pull Request resolved: #49097
Test Plan:
- Verify it doesn't throw any error on runtime anymore for Android.
- iOS behaviour should not be impacted as changes are Android specific
In the RNTester, you can use the following component:
```tsx
import * as React from 'react';
import {Image, View} from 'react-native';
function Playground() {
return (
<View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
<Image
defaultSource={require('../../assets/bandaged.png')}
source={{
uri: 'https://i.natgeofe.com/n/548467d8-c5f1-4551-9f58-6817a8d2c45e/NationalGeographic_2572187_4x3.jpg',
}}
style={{width: 200, height: 200}}
/>
</View>
);
}
```
Also, this `defaultSource` prop is ignored in debug builds for Android ([as per the docs](https://reactnative.dev/docs/image#defaultsource)) – but I've verified we get the defaultSource as a string, which is what we expect on the native side:
<details>
<summary>Screenshot of the Android logs</summary>

</details>
Reviewed By: javache
Differential Revision: D69052723
Pulled By: cortinico
fbshipit-source-id: 2860dd4c18cefcfcbc4e39f94dfa6305f45773a3defaultSource runtime error (#49097)1 parent 282cdc9 commit 665212e
4 files changed
Lines changed: 7 additions & 6 deletions
File tree
- packages/react-native
- Libraries
- Image
- __tests__/__snapshots__
- ReactAndroid/src/main/java/com/facebook/react/views/image
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
178 | 179 | | |
179 | 180 | | |
180 | 181 | | |
| 182 | + | |
181 | 183 | | |
182 | 184 | | |
183 | 185 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
45 | | - | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 86 | + | |
88 | 87 | | |
89 | 88 | | |
90 | 89 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5065 | 5065 | | |
5066 | 5066 | | |
5067 | 5067 | | |
5068 | | - | |
| 5068 | + | |
5069 | 5069 | | |
5070 | 5070 | | |
5071 | 5071 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
0 commit comments