App crashes after setting state from asyncstorage/
See original GitHub issueReact Native version:
System:
OS: Linux 5.0 Ubuntu 18.04.3 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i7-5500U CPU @ 2.40GHz
Memory: 152.31 MB / 7.70 GB
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 10.16.3 - /usr/local/bin/node
Yarn: 1.19.1 - /usr/bin/yarn
npm: 6.13.0 - /usr/local/bin/npm
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
Steps To Reproduce
- On click I wanted to remove a link
function remove(index) {
AsyncStorage.setItem(
'links',
JSON.stringify(Array.from(links).filter((item, i) => i !== index)),
).then(() =>
AsyncStorage.getItem('links')
.then(link => {
setLinks(JSON.parse(link));
})
.then(() => ToastAndroid.show('Deleted', ToastAndroid.SHORT)),
);
}
Describe what you expected to happen: View should be updated but I get this error.
Snack, code example, screenshot, or link to a repository: https://github.com/a-c-sreedhar-reddy/Link/blob/master/pages/Home.js#L26
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
React Native: Async Storage setItem causing app to crash
What is happening: When I press on the button to save it (setItem) or when I call save() in the useEffect it crashes...
Read more >Computer Crashes with Set State and async Storage ... - Reddit
im using a tinder swiper library to show the user quotes. when they swipe down they see a new quote. whenever they leave...
Read more >@react-native-community/async-storage Code Examples | Snyk
Learn more about how to use @react-native-community/async-storage, based on ... If the app crashed last time, don't restore nav state log("DID CRASH?
Read more >[Solved]-How to clear AsyncStorage in React-Native?
React Native - How to store auth token and navigate to other screen after login? Proguard app crash (Caused by: java.lang.NoSuchFieldError: no "Lcom/facebook/ ......
Read more >State persistence | React Navigation
You might want to save the user's location in the app, so that they are immediately returned to the same location after 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
My issue was I was importing
TouchableOpacity
fromRNGestureHandler
. When imported fromreact-native
there is no issue.@Simek yeah i am using .then with them.