an experiment in putting together a wiki and an object-oriented mud.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
the-forest/client/src/clientStuff.jsx

14 lines
580 B

import { useNavigate } from 'react-router-dom';
import { postLogOut } from './apiTools.jsx';
// New hook to make links use the react-router `navigate` method instead of default browser behavior.
export function useFixLinks() {
// spread this return value on <a/> elements in order to make them navigate
const navigate = useNavigate();
return { onClick: (e) => {
if (e.target.tagName != "A") { return; }
if (!e.target.href.includes(window.location.origin)) { return; }
e.preventDefault();
navigate(e.target.href.replace(window.location.origin, ""));
}};
}