React Hook“useHistory”在函數“header”中被調用,它既不是 React 函數組件也不是自定義 React Hook 函數下面是我的代碼import { Link, useHistory } from 'react-router-dom'function header() { let history = useHistory() return ( <header> <div className="header_buttons"> <Link onClick={history.push('/auth/login')} to='/auth/login'> <a href="" className='primary-link'>Login</a> </Link> </div> </header> )}export default header下面是我得到的錯誤Failed to compile../src/Header/header.js Line 6:19: React Hook "useHistory" is called in function "header" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks
React 歷史掛鉤無法正常工作
ITMISS
2023-05-25 16:00:02