I am developing a app with react-native and aws amplify. There was any problem but I suddenly got the error below as soon as I started the app.
AsyncStorageCache - Failed to set item Error: database or disk is full (code 13 SQLITE_FULL)
So, I wrote the code below.
import AsyncStorage from '@react-native-async-storage/async-storage';
...
...
useEffect(() => {
aStorage();
}, []);
const aStorage = async () => {
let listKey = [];
const allKeys = await AsyncStorage.getAllKeys();
for (const key of allKeys) {
if (key.includes('@AmplifyDatastore')) listKey.push(key);
}
const res = await AsyncStorage.multiRemove(listKey);
};
...
...
After add this code, the error above is gone. But There is a problem.
The app I developed uses AWS Amplify's Auth, and once I log in, automatically log in even after I shut down the app and run it again.
When logged in, 'dbUser' is set, and the app navigates to 'MainTab'. Otherwise, if not logged in, it navigates to 'SignNavi'.
Belows are my navigation code.
...
...
<Stack.Navigator screenOptions={{headerShown: false}}>
{!dbUser ? (
<Stack.Screen name="LogIn" component={SignNavi} />
) : (
<Stack.Screen name="Tabs" component={MainTab} />
)}
</Stack.Navigator>
);
...
...
};
After adding the code related to AsyncStorage, I couldn't log in automatically. I initially assumed that the login information was saved in AsyncStorage, but it wasn't. When I remove the AsyncStorage-related code while automatic login is not occurring, it logs in again automatically
I'd appreciate it if you could tell me how to maintain auto-login with the AsyncStorage code, or what's wrong with the code above.
Thanks.