Navigate JS -> Location

PHOTO EMBED

Mon Jan 22 2024 05:00:23 GMT+0000 (Coordinated Universal Time)

Saved by @KhanhDu #javascript

import { useNavigate } from "react-router-dom";

const ProfileOne = () => {
  const navigate = useNavigate();
  const data = { name: "John", age: 30 };

  const handleClick = () => {
    navigate("/profile-two", { state: data });
  };

  return <button onClick={handleClick}>Go to ProfileTwo</button>;
};

export default ProfileOne;
content_copyCOPY

https://dev.to/esedev/how-to-pass-and-access-data-from-one-route-to-another-with-uselocation-usenavigate-usehistory-hooks-1g5m