如何在React Native中显示一次屏幕?

时间:2020-09-18 21:57:45

标签: reactjs react-native react-native-navigation

当用户首次打开应用程序时(如欢迎屏幕),我如何仅向用户显示一次屏幕?我希望用户在下一个开口中看到secondScreen。

App.js屏幕:

import React from "react";
import "react-native-gesture-handler";
import { NavigationContainer } from "@react-navigation/native";
import { createStackNavigator } from "@react-navigation/stack";

import firstScreen from "./src/screens/firstScreen.js";
import secondScreen from "./src/screens/secondScreen,js";

const Stack = createStackNavigator();

function App() {
  
  return (
    <NavigationContainer>
      <Stack.Navigator>
           <Stack.Screen
             name="First"
             component={firstScreen}
             options={{
               headerShown: false,
             }}
           />
          <Stack.Screen
            name="Second"
            component={secondScreen}
            options={{
              headerShown: false,
            }}
          />
      </Stack.Navigator>
    </NavigationContainer>
  );
}

export default App;

2 个答案:

答案 0 :(得分:2)

您可以将值存储在本地存储中。也许使用useEffect进行检查并为该检查设置状态。然后,您可以有条件地渲染。希望能给您一个想法。

答案 1 :(得分:0)

ALTER