1. useHistory()
import { useHistory } from 'react-router-dom';
export default function Button() {
const history = useHistory();
function click() {
history.push("/");
}
return <button onClick={click}>버튼</button>
}
라우팅에 필요한 history를
withRouter 의 도움 없이 사용하게 해주는 Hook 입니다.