问题描述
我正在创建一个带有一些预定义值的表单,我想在提交表单后路由到仪表板页面。我在表单的 onsubmit 上使用 handleLoginSubmit func。为此,我有以下代码:
handleLoginSubmit = (e) => {
e.preventDefault();
let hardcodedCred = {
email: "[email protected]",password: "password123",};
if (
this.state.email == hardcodedCred.email &&
this.state.password == hardcodedCred.password
) {
//combination is good. Log them in.
//this token can be anything. You can use random.org to generate a random string;
// const token = "123456abcdef";
// sessionStorage.setItem("auth-token",token);
//go to www.website.com/todo
// history.push("/dashboard");
this.props.history.push("/dashboard");
// console.log(this.state.route);
console.log(this.context);
console.log("logged in");
// <Link to={location} />;
} else {
//bad combination
alert("wrong email or password combination");
}
};
但是,我收到错误消息,指出历史未定义。 请帮帮我
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)