Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 685 Bytes

use-query-error-reset-boundary.zh.mdx

File metadata and controls

25 lines (22 loc) · 685 Bytes

useQueryErrorResetBoundary

这个 hook 将重置最近的 QueryErrorResetBoundary 内的任何查询错误。如果没有定义边界,它将在全局范围内重置这些错误:

import { useQueryErrorResetBoundary } from "quaere";
import { ErrorBoundary } from "react-error-boundary";

const App: React.FC = () => {
  const { reset } = useQueryErrorResetBoundary();
  return (
    <ErrorBoundary
      onReset={reset}
      fallbackRender={({ resetErrorBoundary }) => (
        <div>
          出现了一个错误!
          <Button onClick={() => resetErrorBoundary()}>重试</Button>
        </div>
      )}
    >
      <Page />
    </ErrorBoundary>
  );
};