Replies: 1 comment 1 reply
-
As a workaround, in my root.tsx, I now do: declare global {
interface Window {
solid_history?: string[]
}
}
export default function App() {
onMount(() => {
document.body.style.background = '#3F565E';
});
createEffect(() => {
// subscribe to the location and push it on the history stack
const path = useLocation().pathname;
console.log('location changed: ', path);
if (window.solid_history) {
window.solid_history.push(path);
} else {
window.solid_history = [path];
}
});
// ... which I can then read in pages as: const solid_history = window.solid_history;
const prevPath = solid_history && solid_history.length > 1 && solid_history[solid_history.length - 2]; |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In react-router we had a
useHistory
hook that allows us to base logic on our current site on the route that the user navigated through the SPA to the current location.useLocation
gives us the current location but often it would be helpful to know the history how the user got to it :)Beta Was this translation helpful? Give feedback.
All reactions