AsyncStorage doesn't work with react-native
See original GitHub issueI 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:
- Created 3 years ago
- Comments:18 (10 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It works very well now 👍
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. 👍