This hook allows the programmer to navigate the user to a new page without the user interacting. Usage of this hook should be uncommon.
Example:
import { useNavigate } from 'react-router-dom';
function ExampleComponent() {
const navigate = useNavigate();
const handleClick = () => {
// Navigate to a new page
navigate('/new-page');
};
return (
<button onClick={handleClick}>
Go to New Page
</button>
);
}