React Native-创建一个登录和注册页面,在有效时导航到主页



,我有个问题要问你

我必须开发一个React Native应用程序,它是一个社交网络。

我的问题是,如何创建一个登录和注册页面,使用路由来搜索和插入凭据。

之后,我想将经过身份验证的用户重定向到应用程序的主页。

为了做到这一点,我正在使用Laravel API。

你能帮我吗?

非常感谢!

如何在登录时获得电子邮件和密码:(既然我回答了你的另一个问题(:

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>
)
}

它看起来像这样。在AuthContext中编写的登录方法中,您会检查凭据是否正确,如果正确,则检索userToken(+可能还有一些其他详细信息(并将其设置为状态。我不能再帮你了,因为我对flatAPI 了解不多

相关内容

最新更新