Viewing docs for an older release. View latest

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.

import { useRevalidator } from "@remix-run/react";

function WindowFocusRevalidator() {
  let revalidator = useRevalidator();

  useFakeWindowFocus(() => {
    revalidator.revalidate();
  });

  return (
    <div hidden={revalidator.state === "idle"}>
      Revalidating...
    </div>
  );
}

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

Docs and examples licensed under MIT