mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-05-23 14:57:13 +00:00
[fix] Image 'source' prop update when missing in initial render
Close #811
This commit is contained in:
committed by
Nicolas Gallagher
parent
fb4635e013
commit
748b2d0f3f
@@ -180,6 +180,20 @@ describe('components/Image', () => {
|
||||
.attr('src')
|
||||
).toBe(uriTwo);
|
||||
});
|
||||
|
||||
test('is correctly updated when missing in initial render', () => {
|
||||
jest.useFakeTimers();
|
||||
const uri = 'https://testing.com/img.jpg';
|
||||
const component = mount(<Image />);
|
||||
component.setProps({ source: { uri } });
|
||||
jest.runOnlyPendingTimers();
|
||||
expect(
|
||||
component
|
||||
.render()
|
||||
.find('img')
|
||||
.attr('src')
|
||||
).toBe(uri);
|
||||
});
|
||||
});
|
||||
|
||||
describe('prop "style"', () => {
|
||||
|
||||
+2
-2
@@ -168,8 +168,8 @@ class Image extends Component<*, State> {
|
||||
if (uri !== nextUri) {
|
||||
ImageUriCache.remove(uri);
|
||||
const isPreviouslyLoaded = ImageUriCache.has(nextUri);
|
||||
isPreviouslyLoaded && ImageUriCache.add(uri);
|
||||
this._updateImageState(getImageState(uri, isPreviouslyLoaded));
|
||||
isPreviouslyLoaded && ImageUriCache.add(nextUri);
|
||||
this._updateImageState(getImageState(nextUri, isPreviouslyLoaded));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user