我是 React 新手,我想向新用户展示我的应用程序的工作原理。 我怎样才能做到这一点?
我需要从 npm 下载一些东西吗?
最佳答案
您可以使用 AsyncStorage 来实现这一点。 AsyncStorage 是一个未加密的、异步的、持久的键值存储系统,对于应用程序来说是全局的。应该使用它来代替 LocalStorage。
import {AsyncStorage} from 'react-native';
const tutorialShown = async () => {
return await AsyncStorage.getItem('@myApp:TUTORIAL_SHOWN');
}
// somewhere in your render method
if (!tutorialShown()) {
return <Tutorial />
}
//somewhere in your Tutorial's componentDidMount
AsyncStorage.setItem('@myApp:TUTORIAL_SHOWN')
详细信息:https://facebook.github.io/react-native/docs/asyncstorage
关于javascript - 检查用户是否首次使用react-native访问应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59442079/