This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useFetcher } from "@remix-run/react"; | |
import { useCallback, useMemo } from "react"; | |
export function useRevalidator() { | |
let fetcher = useFetcher(); | |
let revalidate = useCallback( | |
() => { | |
fetcher.submit(null, { action: "/", method: "post" }); | |
}, | |
// eslint-disable-next-line react-hooks/exhaustive-deps | |
[], | |
); | |
return useMemo(() => ({ revalidate }), [revalidate]); | |
} | |
///////////////////// | |
// in root.tsx | |
export function action() { | |
return { ok: true }; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment