Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

useNavigate

// React Router v6
import { useNavigate } from 'react-router-dom';

export function GoHome() {
  let navigate = useNavigate();
  const handleClick = e => {
    e.preventDefault();
    navigate('/home');
  }
  return <button onClick={handleClick}>Go to Home</button>
}
Source by reactrouter.com #
 
PREVIOUS NEXT
Tagged: #useNavigate
ADD COMMENT
Topic
Name
4+1 =