This repository was archived by the owner on Apr 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -167,6 +167,30 @@ export default function imageCacheHoc(Image, options = {}) {
167
167
168
168
}
169
169
170
+ async componentWillReceiveProps ( nextProps ) {
171
+ const uri = traverse ( this . props ) . get ( [ 'source' , 'uri' ] ) ;
172
+ const nextUri = traverse ( nextProps ) . get ( [ 'source' , 'uri' ] ) ;
173
+ if ( uri === nextUri ) return ;
174
+
175
+ const fileName = await this . fileSystem . getFileNameFromUrl ( uri ) ;
176
+ const nextFileName = await this . fileSystem . getFileNameFromUrl ( nextUri ) ;
177
+
178
+ FileSystem . unlockCacheFile ( fileName , this . componentId ) ;
179
+ FileSystem . lockCacheFile ( nextFileName , this . componentId ) ;
180
+
181
+ const { permanent } = this . props ;
182
+ let localFilePath = null ;
183
+ try {
184
+ localFilePath = await this . fileSystem . getLocalFilePathFromUrl ( nextUri , ! ! permanent ) ;
185
+ } catch ( error ) {
186
+ console . warn ( error ) ; // eslint-disable-line no-console
187
+ }
188
+
189
+ if ( this . _isMounted && localFilePath ) {
190
+ this . setState ( { localFilePath } ) ;
191
+ }
192
+ }
193
+
170
194
async componentWillUnmount ( ) {
171
195
172
196
// Track component mount status to avoid calling setState() on unmounted component.
@@ -207,4 +231,4 @@ export default function imageCacheHoc(Image, options = {}) {
207
231
208
232
} ;
209
233
210
- }
234
+ }
You can’t perform that action at this time.
0 commit comments