I'm using useNavigate to go to the component and need to pass data (a state) to this this ChatRoom component when I click a button. This component is on the route /chatroom.
I'm using React Router Dom v6. I have read the documentation but I cannot find what I'm looking for.
export default function Home() {
const [username, setUsername] = useState("");
const [room, setRoom] = useState("");
const navigate = useNavigate();
const handleClick = () => {
navigate("/chatroom");
};
return (<button
type="submit"
className="btn"
onClick={() => {
handleClick();
}}
>
Join Chat
</button>
)}