我有一个使用 react-native-swiper 制作的屏幕,我在其中介绍了应用程序的工作原理,但我只想在用户第一次打开应用程序时显示此屏幕。
我怎样才能做到这一点?
我有一个使用 react-native-swiper 制作的屏幕,我在其中介绍了应用程序的工作原理,但我只想在用户第一次打开应用程序时显示此屏幕。
我怎样才能做到这一点?
您可以将 bool 值存储在本地存储中,甚至使用 expo SecureStore 包存储在安全存储中。然后在应用程序启动时检查商店中的该值。
import * as SecureStore from 'expo-secure-store';
const app = ()=>{
useEffect(()=>{
const getStoredValue = async ()=> {
const introduction = await SecureStore.getItemAsync("introduction");
//use this variable to determine if you want to run the introduction.
//if introduction doesn't exist in the secure store create one
if (introduction === null ) {
try {
SecureStore.setItemAsync("Introduction", true);
}
catch (ex) {}
}
getStoredValue();
},[]);
}