我目前正在努力解决当用户单击一个将为他们注册帐户的按钮时如何重定向到主页:我当前的设置是这样的
function Application() {
const user = useContext(UserContext);
return (
user ?
<Router>
<LandingScreen path="landingscreen"/>
</Router>
:
<Router>
<SignUp path="signUp" />
<SignIn path="/" />
</Router>
);
}
export default Application;
const SignIn = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState(null);
const signInWithEmailAndPasswordHandler = (event,email, password) => {
event.preventDefault();
auth.signInWithEmailAndPassword(email, password).catch(error => {
setError("Error signing in with password and email!");
console.error("Error signing in with password and email", error);
});
};
我将如何添加一个函数 signInWithEmailAndPasswordHandler 以便在调用它时将用户重定向到 /landingscreen?我已经阅读了到达文档,但我是 JSX 的新手,并且很难实现这一点。