[英]Login Component Error on React.js (codesandbox attached)
I am a new programmer and I recently started following a Login Form tutorial, and I am experiencing a couple of issues with it.我是一名新程序员,最近开始学习登录表单教程,但遇到了一些问题。
Project Overview:项目概况:
As previously described, it is a login form made with create-react-app.如前所述,它是使用 create-react-app 制作的登录表单。 The objective is for the user to be able to login, if it is successful, it will log
"Logged In"
on the console.目的是让用户能够登录,如果成功,它将
"Logged In"
。 If there are errors or if its unsuccessful, it will log "Details Do Not Match"
.如果有错误或不成功,它将记录
"Details Do Not Match"
。
The Problem:问题:
Though I followed this tutorial line-by-line, there is an unseen error in my code that causes the console to log "Details Do Not Match"
.尽管我逐行遵循本教程,但我的代码中有一个看不见的错误导致控制台记录
"Details Do Not Match"
。 I am curious to see where I might have written the code incorrectly.我很想知道我可能在哪里写错了代码。
Below I've attached a working Codesandbox link of my code:下面我附上了我的代码的工作 Codesandbox 链接:
https://codesandbox.io/s/project-zi3un5 https://codesandbox.io/s/project-zi3un5
You had a minor typo on line 17. You were comparing details.email
to adminUser
instead of adminUser.email
您在第 17 行有一个小错字。您将
details.email
与adminUser
而不是adminUser.email
进行比较
It should read:它应该是:
if (details.email === adminUser.email && details.password === adminUser.password) {
console.log("Logged In");
setUser({
name: details.name,
email: details.email
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.