react-native-async-storage / async-storage

An asynchronous, persistent, key-value storage system for React Native.
https://react-native-async-storage.github.io/async-storage/
MIT License
4.61k stars 458 forks source link

fix: check directory before call delete on iOS #1066

Closed camilossantos2809 closed 4 months ago

camilossantos2809 commented 4 months ago

Summary

Before executing the clear method on iOS, check if the directory exists using RCTGetStorageDirectory to avoid throwing an error.

Fixes #1020

Test Plan

To test this change I created an app from scratch and call await AsyncStorage.clear(). The component code is available on gist

before:

https://github.com/react-native-async-storage/async-storage/assets/20076881/0a7e7881-6404-4260-bc58-d23179b29f18

after:

https://github.com/react-native-async-storage/async-storage/assets/20076881/5cafc379-839d-45cf-9c0b-76a2855358e0

AsyncStorageBot commented 4 months ago

:tada: This PR is included in version 1.22.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: