mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
[change] remove componentWillReceiveProps from Image
This commit is contained in:
@@ -160,23 +160,20 @@ class Image extends Component<*, State> {
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
componentDidUpdate(prevProps) {
|
||||
const prevUri = resolveAssetUri(prevProps.source);
|
||||
const uri = resolveAssetUri(this.props.source);
|
||||
if (prevUri !== uri) {
|
||||
ImageUriCache.remove(prevUri);
|
||||
const isPreviouslyLoaded = ImageUriCache.has(uri);
|
||||
isPreviouslyLoaded && ImageUriCache.add(uri);
|
||||
this._updateImageState(getImageState(uri, isPreviouslyLoaded));
|
||||
}
|
||||
if (this._imageState === STATUS_PENDING) {
|
||||
this._createImageLoader();
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
const uri = resolveAssetUri(this.props.source);
|
||||
const nextUri = resolveAssetUri(nextProps.source);
|
||||
if (uri !== nextUri) {
|
||||
ImageUriCache.remove(uri);
|
||||
const isPreviouslyLoaded = ImageUriCache.has(nextUri);
|
||||
isPreviouslyLoaded && ImageUriCache.add(nextUri);
|
||||
this._updateImageState(getImageState(nextUri, isPreviouslyLoaded));
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
const uri = resolveAssetUri(this.props.source);
|
||||
ImageUriCache.remove(uri);
|
||||
|
||||
Reference in New Issue
Block a user