AsyncStorage.setItem not working as expected on iOS
See original GitHub issueCurrent behavior
Async Storage not working with very basic use case. When I changed my import from using the extracted repo import AsyncStorage from '@react-native-community/async-storage';
to the core repoimport AsyncStorage from 'react-native'
it works.
saveFoo(template) {
AsyncStorage.getItem('savedFoos').then(b => {
if (b == null) {
AsyncStorage.setItem('savedFoos', JSON.stringify([template]));
}
else {
var savedFoos = JSON.parse(b);
savedFoos.push(template);
AsyncStorage.setItem('savedFoos', JSON.stringify(savedFoos));
}
});
}
Expected behavior
works
nothing was set to asyncstorage. SetItem failed.
Repro steps
above code
Environment
- Async Storage version: “@react-native-community/async-storage”: “github:react-native-community/async-storage”,
- React-Native version: RN 60.4
- Platform tested: iOS
- Logs/Error that are relevant:
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
AsyncStorage.setItem not working as expected on iOS #195
Async Storage not working with very basic use case. When I changed my import from using the extracted repo import AsyncStorage from '@react- ......
Read more >react native Async Storage not working - Stack Overflow
AsyncStorage is asynchronous :-). The committed value isn't available until its returned promise resolves.
Read more >Async Storage in React Native: How to Do It Right | Waldo Blog
Learn how to implement Async Storage to store data locally in the React Native ... It will start the React Native app on...
Read more >Asyncstorage React Native | Async Storage Tutorial - YouTube
If you require to get up and running with async storage in your application for ios or android, this video will use the ......
Read more >A guide to React Native's AsyncStorage - LogRocket Blog
The setItem method saves data to the AsyncStorage and allows a key and a value. Here, the key is a string that the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Krizzu genius. I removed all the
import AsyncStorage from 'react-native'
from all my files and used onlyimport AsyncStorage from '@react-native-community/async-storage';
across my entire project and now it seems to be working.@jordangrant exactly same issue I had. worked for me too. amazing! I’ve pulled so much hair over it 👍