- SDK Version: 44.0.5
- Platforms: Android/iOS
I am storing a file in FileSystem.cacheDirectory
and want to delete this file on componentWillUnmount. Below is the code snippet I am trying but no luck.
useEffect(() => () => { FileSystem.deleteAsync(fileUri) })
In another screen, when I check for the file info
const { exists } = await FileSystem.getInfoAsync(fileUri);
exists
value is true
Isn’t it possible to delete a file on componentWillUnmount? How to delete cache files which are required only in the current screen and can be delete while moving to another screen?