useRevalidator

This hook is simply a re-export of React Router’s useRevalidator.

This hook allows you to revalidate the data for any reason. React Router automatically revalidates the data after actions are called, but you may want to revalidate for other reasons like when focus returns to the window.

  1. import { useRevalidator } from "@remix-run/react";
  2. function WindowFocusRevalidator() {
  3. const revalidator = useRevalidator();
  4. useFakeWindowFocus(() => {
  5. revalidator.revalidate();
  6. });
  7. return (
  8. <div hidden={revalidator.state === "idle"}>
  9. Revalidating...
  10. </div>
  11. );
  12. }

For more information and usage, please refer to the React Router useRevalidator docs.