'React Native - Making a login and register page that when valid, naviguate to the homepage
I have a question for you,
I have to developp a React Native application that is a social network.
My question is, how to create a login and a register page that use route to search and insert credentials.
After that, i'd like to redirect authenticated users to the Homepage of the application.
To do that I am using Laravel API.
Could you help me ?
Thanks you very much !
Solution 1:[1]
How to get Email and Password on Login: (Since I answered your other question):
const LoginScreen = () => {
const { login } = useAuth();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const handlePress = () => {
login(email, password);
}
return (
<View>
<YourInput
value={email}
placeholder="Email"
onChange={setEmail}
/>
<YourInput
value={password}
placeholder="Password"
onChange={setPassword}
/>
<YourButton title="Login" onPress={handlePress} />
</View>
)
}
It would look something like this. In your login Method that you write in the AuthContext, you would than check if the credentials are correct and if so, retrieve the userToken (+ maybe some other details) and set it in the state. I can't help you further since I don't know much about flatAPI
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
