本页还没有译文
本页 11 段还没译成简体中文,下面显示的是英文原文。useRevalidator
还没翻译译自英文(reactrouter.com)本页 11 段都还没译
useRevalidator
Framework Data
Summary
Revalidate the data on the page for reasons outside of normal data mutations
like Window focus
or polling on an interval.
Note that page data is already revalidated automatically after actions.
If you find yourself using this for normal CRUD operations on your data in
response to user interactions, you're probably not taking advantage of the
other APIs like useFetcher, Form, useSubmit that do
this automatically.
import { useRevalidator } from "react-router";
function WindowFocusRevalidator() {
const revalidator = useRevalidator();
useFakeWindowFocus(() => {
revalidator.revalidate();
});
return (
<div hidden={revalidator.state === "idle"}>
Revalidating...
</div>
);
}Signature
function useRevalidator(): {
revalidate: () => Promise<void>;
state: DataRouter["state"]["revalidation"];
}Returns
An object with a revalidate function and the current revalidation
state
AI 翻译查看英文原文