我有一个应用程序,它显示了我从 API 加载的多个图像。现在的问题是某些图像已过期,这导致 Android 出现问题,在 Android 中,一旦过期图像加载到屏幕上,屏幕就会开始滞后。
我试过用onError={() => this.imgRefs[img_unique_id].setNativeProps({src: [{uri: this.state.workingUri}]})}
这种方法替换图像源,但它不起作用。我不能使用本地状态,因为它没有将输出保存在本地状态。
我试过下面的代码
<Image
source={image.url}
progressiveRenderingEnabled={true}
ref={item.id}
onError={(e) => this.refs[item.id].setNativeProps({source: [{uri: "working image URL"}]})}
resizeMethod={"scale"}>
</Image>
上面的代码给了我一个未定义的 setNativeProps 错误,如果我不在 android 上使用 onError,它会显示内存泄漏错误。