fix: Performance degredation when multiple tabs are open

This commit is contained in:
Tom Moor
2022-10-10 18:47:37 -04:00
parent 65e903582f
commit 5ee3f2a608
3 changed files with 23 additions and 9 deletions

View File

@@ -1,10 +1,17 @@
import * as React from "react";
import usePersistedState from "~/hooks/usePersistedState";
export default function useLastVisitedPath() {
const [lastVisitedPath, setLastVisitedPath] = usePersistedState(
/**
* Hook to set locally and return the path that the user last visited. This is
* used to redirect the user back to the last page they were on if preferred.
*
* @returns A tuple of the last visited path and a method to set it.
*/
export default function useLastVisitedPath(): [string, (path: string) => void] {
const [lastVisitedPath, setLastVisitedPath] = usePersistedState<string>(
"lastVisitedPath",
"/"
"/",
{ listen: false }
);
const setPathAsLastVisitedPath = React.useCallback(