You can use useHistory
hook since react-router v5.1.0.
The
useHistory
hook gives you access to the history instance that you may use to navigate.
import React from 'react'
import { useHistory } from 'react-router-dom'
export default function SomeComponent() {
const { push } = useHistory()
...
<button
type="button"
onClick={() => push('/some-link')}
>
Some link
</button>
...
}