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.

AsyncStorage doesn't work with react-native

See original GitHub issue

I don’t see how this should currently work, since AsyncStorage is async… ?

At least I don’t know how to make it work in my App. It doesn’t restore / or save the data.

Any hints would be helpful. Thank you ❤️

import React from 'react';
import AsyncStorage from '@react-native-community/async-storage';
import {
  StateMachineProvider,
  createStore,
  setStorageType,
} from 'little-state-machine';

import App from './App';

setStorageType(AsyncStorage);

const data: LittleState = {
  xFormData: {},
};

createStore(data);

const AppContainer = () => (
    <StateMachineProvider>
        <App />
    </StateMachineProvider>
);

export default AppContainer;

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
happyfloatcommented, Jul 28, 2020

It works very well now 👍

1reaction
happyfloatcommented, Jul 24, 2020

Wow, that was quick… I couldn’t count on that. I already switched my green-field project to React’s new recoil library. But the react-native support is also not really there yet (only with a patch)… I will see how it is going and if necessary switch back again.

The react world is moving way to fast… for my API cache/state I’m going with react-query.

Anyway, I will try your change later today to give you feedback if it works on my side! Thank you very much. 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async storage not working to set or get on React Native
At my end AsyncStorage.getItem('foo') works when I used StrigyFy at the time of set item.
Read more >
AsyncStorage not working properly · Issue #219 · react-native ...
Basically setup my authentication with asyncstorage, if user is signed in it shows dashboard else login screen. But now user login and open...
Read more >
AsyncStorage - React Native
AsyncStorage is an unencrypted, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of ...
Read more >
How To Use React Native AsyncStorage - JScrambler Blog
AsyncStorage is a simple, asynchronous, unencrypted by default module that allows you to persist data offline in React Native apps.
Read more >
Async Storage in React Native: How to Do It Right | Waldo Blog
Learn how to implement Async Storage to store data locally in the React Native app.
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