使い方
import { ExceptionPage } from './ExceptionPage.jsx'
// One variant per route: app/not-found.jsx, a 403 from the server, an error boundary, a failed load.
<ExceptionPage
locale="en"
variant="server-error" // 'not-found' | 'no-access' | 'server-error' | 'offline'
reference={error.digest}
onSearch={(words) => router.push('/search?q=' + encodeURIComponent(words))}
onAction={async (variant, which) => {
if (variant === 'server-error' && which === 'primary') return reset()
if (variant === 'offline' && which === 'primary') return await reload() // false keeps counting down
if (variant === 'not-found' && which === 'primary') router.push('/')
}}
/>プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 組み込みの文言の言語。 |
variant | 'not-found' | 'no-access' | 'server-error' | 'offline' | — | 表示するページ。指定しないと、上のセグメントで 4 つを切り替えられます。 |
reference | string | — | サーバーエラーで表示するリクエスト番号やエラー番号(コピーボタンつき)。 |
retryIn | number | 10 | オフライン時の自動再試行の間隔(秒)。 |
onAction | (variant, which: 'primary' | 'secondary' | 'link', link?) => Promise<boolean | void> | void | — | 操作が押されたとき。false を返すと失敗扱い(オフラインならカウントダウンを続けます)。 |
onSearch | (words: string) => void | — | 「見つからない」ページで検索したとき。 |
labels | object | — | 組み込みの文言を置き換えます(キーは copy.js と同じ)。 |
プロジェクトに追加
プロンプトを Codex や Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込むファイルを示してから、使っているコンポーネントと一緒にブロックを追加します。
ExceptionPage.jsxexception-page.csscopy.jskit.jsxkit.cssui/base-button/ui/copy-button/ui/text-input/ui/segmented-control/tokens.cssREADME.md
ブロック本体、スタイルと文言、共通の kit、使っているコンポーネント、tokens.css が 1 つのフォルダにまとめて入ります。