错误
这是浏览器在网页上显示的错误。
Compiled with problems:X
ERROR
src\components\SignIn.js
Line 5:21: React Hook "useRef" is called in function "signin" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use" react-hooks/rules-of-hooks
Search for the keywords to learn more about each error.SignIn.js
我的代码中使用的部分。
import React, { useRef } from 'react'
import { Card, Button, Form } from 'react-bootstrap'
export default function signin() {
const userRef = useRef()
return (
<>
<Card>
<Card.Body>
<h2 className='text-center mb-4'>Magnet</h2>
<Form>
<Form.Group id="username">
<Form.Label>Username</Form.Label>
<Form.Control type='text' ref={userRef} required />
</Form.Group>
</Form>
</Card.Body>
</Card>
</>
)
}发布于 2022-05-05 18:43:15
你的错误已经有答案了
Line 5:21: React Hook "useRef" is called in function "signin" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use" react-hooks/rules-of-hooks您应该用Signin更改组件名称
https://stackoverflow.com/questions/72132154
复制相似问题