Skip to content

AsyncStorage.setItem not working as expected on iOS #195

Closed
@jordangrant

Description

@jordangrant

Current 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions