简体   繁体   English

react-native 使用 AsyncStorage 的身份验证应用程序

[英]react-native authentification app using AsyncStorage

developers I'm working on a React Native project created with Expo i use * AsyncStorage *to make a user authentication i faced this problem when i use my phone to test my app this is a capture of the error in my phone, but there is not erreur in * Expo DevTools console *开发人员 我正在开发一个使用 Expo 创建的 React Native 项目 我使用 * AsyncStorage * 进行用户身份验证 当我使用手机测试我的应用程序时遇到了这个问题这是我手机中错误的捕获,但是有没有错误 * Expo DevTools 控制台 *

I'm not quite sure about the Expo but since React native 0.60, Facebook removed some of these packages from the react native core to reduce the size because those libs are not necessary for all the users.我不太确定 Expo 但自从 React native 0.60 以来,Facebook 从 react native 核心中删除了其中一些包以减小大小,因为并非所有用户都需要这些库。 So in order to use AsyncStorage, now you have to manually install it using NPM or Yarn first.因此,为了使用 AsyncStorage,现在您必须先使用 NPM 或 Yarn 手动安装它。 So from your screenshot I assume that is true for Expo as well.因此,从您的屏幕截图中,我假设 Expo 也是如此。

However do the following and you will be fine.但是,请执行以下操作,您会没事的。 I assume you have react native version higher than 0.60我假设您的本机版本高于 0.60

if your package manager is Yarn, then: yarn add @react-native-community/async-storage如果您的 package 经理是 Yarn,那么: yarn add @react-native-community/async-storage

or或者

if your package manager is NPM, then: npm i --save @react-native-community/async-storage如果您的 package 管理器是 NPM,则: npm i --save @react-native-community/async-storage

After that, use below code part to update iOS Pods.之后,使用以下代码部分更新 iOS Pod。 Run this from your project root using terminal.使用终端从项目根目录运行它。

cd ios / && pod install && cd...

Now try to run the app.现在尝试运行该应用程序。 App will start to work if there are no any other issues.如果没有任何其他问题,应用程序将开始工作。 For more information about AsynStorage, please use this link .有关 AsynStorage 的更多信息,请使用此链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM