react-router-dom v6
1、useNavigate替代useHistory
在v6版本useHistory
被新hookuseNavigate
代替,用法也发生的很大的变化
//v5
import {
useHistory} from 'react-router-dom'
function ChangePage(){
const history = useHistory()
const handleClick = () => {
history.push('/home')
//history.replace('/home')
//history.go(-1)
//history.goback()
//history.goForward()
}
return(
<button onClick={
handleClick}>跳转</button>
)
}
变为:
//v6
import {
us