question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

App crashes after setting state from asyncstorage/

See original GitHub issue

React 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

  1. 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. Screenshot from 2019-11-23 17-14-52

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:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
a-c-sreedhar-reddycommented, Nov 26, 2019

My issue was I was importing TouchableOpacity from RNGestureHandler. When imported from react-native there is no issue.

0reactions
a-c-sreedhar-reddycommented, Nov 26, 2019

@Simek yeah i am using .then with them.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found