[ad_1]
Requested
Considered
6 occasions
I’ve a React-Native (sdk 46.0) Firebase app. I need to make it in order that when the person is signed in, he strikes from the LoginScreen to to the HomeScreen. Code is proven beneath.
// screens/LoginScreen.js >>
...
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const navigation = useNavigation();
const handleLogin = () => {
auth
.signInWithEmailAndPassword(e-mail, password)
.then((userCredentials) => {
const person = userCredentials.person;
console.log("Logged in with:", person.e-mail);
})
.catch((error) => alert(error.message));
};
...
<View type={kinds.inputContainer}>
<Enter
type={kinds.enter}
blurOnSubmit
autoCorrect={false}
placeholder="jdoe@ernestkoliqi.com"
placeholderTextColor="#666"
worth={e-mail}
onChangeText={(textual content) => setEmail(textual content)}
selectTextOnFocus
keyboardType="email-address"
/>
<Enter
type={kinds.enter}
blurOnSubmit
autoCorrect={false}
placeholder="Password"
placeholderTextColor="#666"
bool={true}
worth={password}
onChangeText={(textual content) => setPassword(textual content)}
selectTextOnFocus
/>
</View>
<View type={kinds.buttonContainerModal}>
<TouchableOpacity onPress={handleLogin}>
<View type={kinds.ctaBtnModal}>
<Textual content type={kinds.loginBtn}>Log In</Textual content>
</View>
</TouchableOpacity>
...
// App.js
...
perform Dwelling() {
return <HomeScreen />;
}
perform Information() {
return <NewsScreen />;
}
perform Calendar() {
return <CalendarScreen />;
}
perform Login() {
return <LoginScreen />;
}
perform Feed() {
return (
<Tab.Navigator
screenOptions={({ route }) => ({
tabBarIcon: ({ centered, colour, dimension }) => {
let iconName;
if (route.identify === "Dwelling") {
iconName = centered ? "house" : "home-outline";
} else if (route.identify === "Information") {
iconName = centered ? "newspaper" : "newspaper-outline";
} else if (route.identify === "Calendar") {
iconName = centered ? "calendar" : "calendar-outline";
}
return <Ionicons identify={iconName} dimension={dimension} colour={colour} />;
},
activeTintColor: Colours.main,
inactiveTintColor: "grey",
showLabel: true,
showIcon: true,
type: {
paddingBottom: 4.25,
paddingTop: 4.25,
},
})}
>
<Tab.Display
identify="Dwelling"
part={Dwelling}
choices={{ headerShown: false }}
/>
<Tab.Display
identify="Calendar"
part={Calendar}
choices={{ headerShown: false }}
/>
<Tab.Display
identify="Information"
part={Information}
choices={{ headerShown: false }}
/>
</Tab.Navigator>
);
}
const Tab = createBottomTabNavigator();
const Stack = createNativeStackNavigator();
export default perform App() {
return (
<SafeAreaView type={kinds.display}>
<StatusBar barStyle="light-content" translucent={true} />
<NavigationContainer theme={appTheme}>
<Stack.Navigator>
<Stack.Display part={Login} choices={{ headerShown: false }} identify="Login" />
<Stack.Display part={Feed} identify="Feed" />
</Stack.Navigator>
<LoginScreen />
</NavigationContainer>
</SafeAreaView>
);
}
...
The code above reveals the file construction and the code contained within the information relative to the subject. How can I handle to alter Stack.Display when person==True?
David Guri is a brand new contributor to this web site. Take care in asking for clarification, commenting, and answering.
Take a look at our Code of Conduct.
default
[ad_2]
