Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

react router how to go back

// To get back to previous url adress:
import { useNavigate } from "react-router-dom";

const MyButton = () => {
  const navigate = useNavigate();

  return (
    <button
      onClick={() => {
        navigate(-1);
      }}
    >
      Click me to go back!
    </button>
  );
};

export default MyButton
 
PREVIOUS NEXT
Tagged: #react #router
ADD COMMENT
Topic
Name
6+4 =