In React Router v5, the useHistory hook is used to navigate programmatically within a functional component.
Usage:
import { useHistory } from 'react-router-dom';
function MyComponent() {
const history = useHistory();
const handleClick = () => {
history.push('/about'); // Navigate to /about
};
return <button onClick={handleClick}>Go to About</button>;
}