asyncstorage

What is the correct way to use AsyncStorage to update state in React-Native?

筅森魡賤 提交于 2019-12-01 01:55:53
I'm trying to make a GET request to a server to retrieve a list of products in JSON form. I then want to put the data into AsyncStorage so I can display the products in the view. What's the correct way to do this? What I've researched: on https://facebook.github.io/react-native/docs/asyncstorage.html , in the example, they explain how to retrieve a value from AsyncStorage, not set it and retrieve it at the same time What I have: componentDidMount () { this.fetchProducts() this._loadInitialState().done(); } _loadInitialState = async () => { try { var value = await AsyncStorage.getItem('products

What is the correct way to use AsyncStorage to update state in React-Native?

邮差的信 提交于 2019-11-30 20:08:26
问题 I'm trying to make a GET request to a server to retrieve a list of products in JSON form. I then want to put the data into AsyncStorage so I can display the products in the view. What's the correct way to do this? What I've researched: on https://facebook.github.io/react-native/docs/asyncstorage.html , in the example, they explain how to retrieve a value from AsyncStorage, not set it and retrieve it at the same time What I have: componentDidMount () { this.fetchProducts() this.

How to retrieve data with AsyncStorage multiGet in React Native

孤人 提交于 2019-11-30 19:21:17
I'm considering how to use React-native AsyncStorage multiGet in docs written: AsyncStorage.multiGet(keys, (err, stores) => { But how those keys should properly look like? Here is how they are set within my application: AsyncStorage.multiSet([['@BarcodeList', JSON.stringify(scanedList)], ['@ScannedBarcode', gotCode]]); It's ok, but how can i retrieve that data with multiGet? With getItem it seems working, what i am doing wrong? both(getItem, multiGet) of them below. AsyncStorage.multiGet(["@BarcodeList", "@ScannedBarcode"]).then((scanedList2, scannedBarcode) => { //AsyncStorage.getItem("

Possible Unhandled Promise Rejection (id:0) Warning

强颜欢笑 提交于 2019-11-30 19:16:12
问题 I am getting the following warning message when my AsyncStorage Item is empty "Possible Unhandled Promise Rejection (id:0)" So my question is: How can I handle a promise rejection? My code: componentDidMount() { try { // This warning only appears when 'connections' item is empty AsyncStorage.getItem('connections').then((token) => { token = JSON.parse(token); const getSectionData = (dataBlob, sectionId) => dataBlob[sectionId]; const getRowData = (dataBlob, sectionId, rowId) => dataBlob[`$

How to retrieve data with AsyncStorage multiGet in React Native

孤街浪徒 提交于 2019-11-30 03:51:36
问题 I'm considering how to use React-native AsyncStorage multiGet in docs written: AsyncStorage.multiGet(keys, (err, stores) => { But how those keys should properly look like? Here is how they are set within my application: AsyncStorage.multiSet([['@BarcodeList', JSON.stringify(scanedList)], ['@ScannedBarcode', gotCode]]); It's ok, but how can i retrieve that data with multiGet? With getItem it seems working, what i am doing wrong? both(getItem, multiGet) of them below. AsyncStorage.multiGet(["

Undefined is not an object (evaluating 'RCTAsyncStorage.multiMerge' (React-native-asyncstorage)

∥☆過路亽.° 提交于 2019-11-29 10:32:59
I am having an issue related to react-native-asyncstorage from here: https://facebook.github.io/react-native/docs/asyncstorage.html When I run react-native run-ios , the following error appears: I am using react-native 0.52.0 and this problem may be due to the dependency of react-native-asyncstorage: react-native-asyncstorage@1.0.0 requires a peer of react-native@^0.47.2 but none is installed. You must install peer dependencies yourself. The odd thing is it works fine for Android, but not for both iOS nor iOS emulator. Can someone help? EDIT I would like to add some points that maybe useful: I

How to test Async Storage with Jest?

a 夏天 提交于 2019-11-29 06:59:47
问题 I'm building an app with React Native. I want to minimize how often I communicate to the database, so I make heavy use of AsyncStorage. There's a lot of room for bugs in the translation between DB and AsyncStorage though. Therefore, I want to make sure that AsyncStorage has the data I believe it does by running automated tests against it. Surprisingly, I haven't found any information on how to do that online. My attempts to do it on my own haven't worked out. Using Jest: it("can read

Undefined is not an object (evaluating 'RCTAsyncStorage.multiMerge' (React-native-asyncstorage)

雨燕双飞 提交于 2019-11-28 03:35:44
问题 I am having an issue related to react-native-asyncstorage from here: https://facebook.github.io/react-native/docs/asyncstorage.html When I run react-native run-ios , the following error appears: I am using react-native 0.52.0 and this problem may be due to the dependency of react-native-asyncstorage: react-native-asyncstorage@1.0.0 requires a peer of react-native@^0.47.2 but none is installed. You must install peer dependencies yourself. The odd thing is it works fine for Android, but not for

Is React Native's Async Storage secure?

两盒软妹~` 提交于 2019-11-27 12:36:00
I want to store sensitive data locally in a React Native app. Is the data only available to the app that wrote it? AsyncStorage is not suitable for storing sensitive information. You might find this useful: https://github.com/oblador/react-native-keychain It uses facebook conceal/android keystore to store encrypted data to SharedPreferences (Android) and keychain on iOS. (I co-authored the lib). Be sure to read the entire readme to understand what it offers. No, AsyncStorage is not secure for sensitive data. AsyncStorage simply saves data to documents on the phone's hard drive, and therefore

Is React Native's Async Storage secure?

人走茶凉 提交于 2019-11-26 13:48:24
问题 I want to store sensitive data locally in a React Native app. Is the data only available to the app that wrote it? 回答1: AsyncStorage is not suitable for storing sensitive information. You might find this useful: https://github.com/oblador/react-native-keychain It uses facebook conceal/android keystore to store encrypted data to SharedPreferences (Android) and keychain on iOS. (I co-authored the lib). Be sure to read the entire readme to understand what it offers. 回答2: No, AsyncStorage is not