Async-storage: [AsyncStorage] Using undefined type for key is not supported.

Created on 25 Mar 2020  路  3Comments  路  Source: react-native-async-storage/async-storage

Current behavior

I'm using AsyncStorage to store some strings. I'm connected with my iPad and getting this warning in the Metro Bundler console.

[AsyncStorage] Using undefined type for key is not supported. This can lead to unexpected behavior/errors. Use string instead.
Key passed: undefined

Wierdly I'm only getting those on my iPad, not on my iOS simulator.

Expected behavior

Everything seems to work. Just want to understand where it comes from?

Environment

  • Async Storage version: 1.8.1
  • React-Native version: 61.5
  • Platform tested: iOS
bug

All 3 comments

IMG_0008

I'm also getting this error alongside, but only on iPad again. I felt like it was about some entries that were in my manifest.json prior. so i wiped it with .clear() but the problem persits.

I found this thread: https://github.com/facebook/react-native/issues/9743
which describes the same issue with AsyncStorage. They provided a solution but it didnt help me to fix my problem.

Hi @farbexot ,

Can you provide some repro steps? It seems like you're passing a variable that is indeed undefined. Have you tried to log the key/value before using Async Storage?

Hi Krizzu,

yes I found the problem. I am using items from a FlatList and have a function that fills up the rows in order to maintain proper layout. The renderItem calls AsyncStorage.getItem() and here the name of the items were undefined as they came from the pesudo-items.

I just added if(item !== undefined) before getItem()

Thanks for your help!

The reason why it was only on my iPad is because I used it in another orientation as the simulator. The simulator wasn't creating the pseudo elements, but the iPad was.

Was this page helpful?
0 / 5 - 0 ratings