Async-storage: TypeError: undefined is not an object (evaluating '_asyncStorage.AsyncStorage.getItem')

Created on 12 Aug 2019  路  6Comments  路  Source: react-native-async-storage/async-storage

Current behavior

I get the above warning and the app gets stuck. Doesn't move ahead.


IMG-20190812-WA0003

Expected behavior

The app should move ahead of splash screen.

Repro steps

Create new app using react-native-cli
Integrate async-storage using yarn
usage:
AsyncStorage.getItem('key1')
.then((response)=>{
AsyncStorge.getItem('key2')
.then((response)=>{
....other code.
})
.catch((error)=>{});
});
.catch((error)=>{});

Is the nesting causing problem?

Environment

  • Async Storage version: on the latest version:

  • React-Native version: 0.60.4

  • Platform tested: Android

Most helpful comment

@King2231

Can you check how you're importing the library? It should be imported as a default:

import AsyncStorage from @react-native-community/async-storage

instead of named value:

import {AsyncStorage} from @react-native-community/async-storage

All 6 comments

Hey @King2231 ,

Nope, it's not nesting issue. From the code snippet you provided, it looks like it has a syntax error - you placed the semicolon after first catch block, making this expression invalid. Try removing it.

Did...doesn't fix the issue...

@King2231

Can you check how you're importing the library? It should be imported as a default:

import AsyncStorage from @react-native-community/async-storage

instead of named value:

import {AsyncStorage} from @react-native-community/async-storage

I assume the issue is solved :)

still got the same problem

@kfbfarley: still got the same problem

This issue is a year old and a lot has changed since. If you're having issues, please open a new one and provide as much details as you can and we'll try to help you.

Was this page helpful?
0 / 5 - 0 ratings