【发布时间】:2021-12-02 10:52:33
【问题描述】:
错误
TypeError: Cannot read properties of undefined (reading 'push')
我的代码
import React from "react";
import { useHistory } from "react-router-dom";
const test = () => {
const history = useHistory();
function buttonPressed() {
history.push("/sus");
}
return (
<div>
<button onClick={() => buttonPressed()}>Brn</button>
</div>
);
};
export default test ;
请帮助我
【问题讨论】:
-
所有 React 组件名称必须以大写字母开头
标签: reactjs