How to use the @react-native-community/async-storage.setItem function in @react-native-community/async-storage

To help you get started, we’ve selected a few @react-native-community/async-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lbryio / lbry-android / app / src / page / firstRun / internal / email-collect-page.js View on Github external
handleChangeText = text => {
    // save the value to the state email
    const { onEmailChanged } = this.props;
    this.setState({ email: text });
    AsyncStorage.setItem(Constants.KEY_FIRST_RUN_EMAIL, text);
    AsyncStorage.setItem(Constants.KEY_EMAIL_VERIFY_PENDING, 'true');
    if (onEmailChanged) {
      onEmailChanged(text);
    }
  };
github MetaMask / metamask-mobile / app / components / Views / Settings / SecuritySettings / index.js View on Github external
if (validate) {
				await Engine.context.KeyringController.exportSeedPhrase(password);
			}

			await AsyncStorage.setItem('@MetaMask:existingUser', 'true');
			if (enabled) {
				const authOptions = {
					accessControl:
						type === 'biometrics'
							? SecureKeychain.ACCESS_CONTROL.BIOMETRY_CURRENT_SET_OR_DEVICE_PASSCODE
							: SecureKeychain.ACCESS_CONTROL.DEVICE_PASSCODE
				};
				await SecureKeychain.setGenericPassword('metamask-user', password, authOptions);

				if (type === 'biometrics') {
					await AsyncStorage.setItem('@MetaMask:biometryChoice', this.state.biometryType);
					await AsyncStorage.removeItem('@MetaMask:passcodeChoice');
					// If the user enables biometrics, we're trying to read the password
					// immediately so we get the permission prompt
					if (Platform.OS === 'ios') {
						await SecureKeychain.getGenericPassword();
					}
				} else {
					await AsyncStorage.setItem('@MetaMask:passcodeChoice', 'true');
					await AsyncStorage.removeItem('@MetaMask:biometryChoice');
				}
			} else {
				await AsyncStorage.removeItem('@MetaMask:biometryChoice');
				await AsyncStorage.removeItem('@MetaMask:passcodeChoice');
			}

			this.props.passwordSet();
github guardian / editions / projects / Mallard / src / App.tsx View on Github external
const persistNavigationState = async (navState: any) => {
    try {
        await AsyncStorage.setItem(persistenceKey, JSON.stringify(navState))
    } catch (e) {
        console.log('Unable to persist state')
    }
}
github ShaMan123 / react-native-math-view / src / android / deprecated / MathProvider.js View on Github external
setDatabaseItem(data) {
        return AsyncStorage
            .setItem(`${this.storageKey}:${data.math}`, JSON.stringify(data))
            .catch(err => {
                if (err.code === 13) this.clearDatabase();
                console.error(err);
            });
    }
github pmusaraj / discourse-mobile-single-site-app / js / App.js View on Github external
skipWelcomeScreen() {
    this.setState({skipLogin: true});
    AsyncStorage.setItem('@Discourse.skipLogin', 'loginSkipped');
  }
github digidem / mapeo-mobile / src / frontend / context / DraftObservationContext.js View on Github external
React.useEffect(() => {
    const { photos, value, observationId } = state;
    AsyncStorage.setItem(
      STORE_KEY,
      JSON.stringify({ photos, value, observationId })
    ).catch(e => {
      log("Error writing to storage", e);
    });
  });
github orangeloops / public-ol-native-template / src / ui / stores / StorageStore.ts View on Github external
async setItem(item: TItem, value: StorageItems[TItem]) {
    return AsyncStorage.setItem(item, value);
  }
github atulmy / fullstack-javascript-architecture / frontend / app / mobile / src / modules / note / Detail / index.js View on Github external
if(note) {
        setNote(note)
      } else {
        isRefreshingToggle(true)
      }

      try {
        const { data } = await detail({ noteId })

        if(data.success) {
          const note = data.data

          setNote(note)

          await AsyncStorage.setItem(CACHE_KEY, JSON.stringify(note))
        }
      } catch(error) {
        dispatch(messageShow({ success: false, message: translate.t('common.error.default') }))
      } finally {
        isRefreshingToggle(false)
      }
    } else {
      navigation.navigate(routesNote.list.name)
    }
  }
github discourse / DiscourseMobile / js / site_manager.js View on Github external
save() {
    AsyncStorage.setItem("@Discourse.sites", JSON.stringify(this.sites)).done();
    this.updateUnreadBadge();
  }
github fidisys / react-native-boilerplate / App / utils / storageService.js View on Github external
const setThemeId = id =>{
  AsyncStorage.setItem('theme_id', id);
}