Dev Helpers
← Back

Transition-wrapped retry

Place this file at app/studio/error.tsx in an App Router project.

Open this example in the interactive library

Source code

"use client";

// app/studio/error.tsx

import { useTransition } from "react";

export default function TransitionWrappedRetry({ reset }: { reset: () => void }) {
  const [pending, start] = useTransition();
  return (
    <div role="alert">
      <p>Unable to load this view.</p>
      <button disabled={pending} onClick={() => start(reset)}>
        {pending ? "Retrying…" : "Retry view"}
      </button>
    </div>
  );
}