【发布时间】:2021-11-14 15:02:14
【问题描述】:
这是我使用 React 用于注册屏幕的代码:
import React, { useCallback } from "react";
import { withRouter } from "react-router";
import app from "../Firebase/firebase";
const Register = ({history}) => {
const handleSignup = useCallback(async event => {
event.preventDefault()
const { email, password } = event.target.elements;
try {
await app
.auth()
.createUserWithEmailAndPassword(email.value, password.value);
history.push("/dashboard")
} catch(error) {
alert(error)
}
}, [history]);
return (
<div>
<p>Register</p>
<Form onSubmit={handleSignup}>
<label>
Email
<input name="email" type="email" placeholder="Email" />
</label>
<label>
Password
<input name="password" type="password" placeholder="Password" />
</label>
<button type="submit">Register</button>
</Form>
</div>
)
}
export default withRouter(Register)
我收到标题中提到的错误,我在这里做错了什么?
在终端中运行 npm i react-router 时,我也遇到了这些错误:npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.16.0 需要 @babel/ 的对等体core@^7.13.0 但没有安装。您必须自己安装对等依赖项。
【问题讨论】:
-
运行 npm install
标签: python javascript reactjs