Parsing local storage data in React Native
See original GitHub issueAs the title says I upgraded to 0.5.0 and it crashes here
[Unhandled promise rejection: SyntaxError: JSON Parse error: Unexpected identifier "object"]
* [native code]:null in parse
- node_modules/offix-client/dist/offline/OfflineStore.js:79:45 in <unknown>
- node_modules/offix-client/dist/offline/OfflineStore.js:32:27 in step
- node_modules/offix-client/dist/offline/OfflineStore.js:7:13 in <unknown>
It looks like the getOfflineData function doesn’t properly handle invalid data from the store. I’m using 0.5.0 on react-native (expo) with AsyncStorage.
Edit: It actually crashes using AsyncStorage no matter what now. It isn’t just with old data. I cleared the data on the simulator and the result is the same. This worked in the previous version without problems.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Parsing JSON file from LocalStorage in to react-native
Hi the data prop of FlatList component accepts only array of values. But you are generating an object in your info.json file.
Read more >React localStorage: set and get items with hooks - CopyCat Blog
Learn the basics of React localStorage. In this tutorial, we'll focus on how to use the localStorage storage type with React and hooks....
Read more >How to Use localStorage with React Hooks to Set and Get Items
localStorage is a web storage object that allows JavaScript sites and apps to keep key-value pairs in a web browser with no expiration...
Read more >Using localStorage with React Hooks - LogRocket Blog
Learn how using localStorage with React Hooks can persist user information in browser storage and share logic between multiple components.
Read more >Local Storage in React - Robin Wieruch
What's important to note is that the data stored in the local storage should be in a JavaScript string format. For example, if...
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 Free
Top 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

Unfortunately my team has decided not to use apollo/graphql for our latest project so I won’t have time to contribute here for some time. I think this issue can be closed since it sounds like the storage abstraction should render it a non-issue.
@AndrewMorsillo Thank you so much for the update!