File tree 2 files changed +16
-2
lines changed
packages/react-native-web/src/exports/Image
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,20 @@ describe('components/Image', () => {
180
180
. attr ( 'src' )
181
181
) . toBe ( uriTwo ) ;
182
182
} ) ;
183
+
184
+ test ( 'is correctly updated when missing in initial render' , ( ) => {
185
+ jest . useFakeTimers ( ) ;
186
+ const uri = 'https://testing.com/img.jpg' ;
187
+ const component = mount ( < Image /> ) ;
188
+ component . setProps ( { source : { uri } } ) ;
189
+ jest . runOnlyPendingTimers ( ) ;
190
+ expect (
191
+ component
192
+ . render ( )
193
+ . find ( 'img' )
194
+ . attr ( 'src' )
195
+ ) . toBe ( uri ) ;
196
+ } ) ;
183
197
} ) ;
184
198
185
199
describe ( 'prop "style"' , ( ) => {
Original file line number Diff line number Diff line change @@ -168,8 +168,8 @@ class Image extends Component<*, State> {
168
168
if ( uri !== nextUri ) {
169
169
ImageUriCache . remove ( uri ) ;
170
170
const isPreviouslyLoaded = ImageUriCache . has ( nextUri ) ;
171
- isPreviouslyLoaded && ImageUriCache . add ( uri ) ;
172
- this . _updateImageState ( getImageState ( uri , isPreviouslyLoaded ) ) ;
171
+ isPreviouslyLoaded && ImageUriCache . add ( nextUri ) ;
172
+ this . _updateImageState ( getImageState ( nextUri , isPreviouslyLoaded ) ) ;
173
173
}
174
174
}
175
175
You can’t perform that action at this time.
0 commit comments