{"id":3886,"date":"2026-11-20T05:27:57","date_gmt":"2026-11-19T20:27:57","guid":{"rendered":"https:\/\/qol-kk.com\/wp2\/?p=3886"},"modified":"2026-11-20T05:27:57","modified_gmt":"2026-11-19T20:27:57","slug":"20261118-plan108","status":"publish","type":"post","link":"https:\/\/qol-kk.com\/wp2\/blog\/2026\/11\/20\/20261118-plan108\/","title":{"rendered":"React \u306e\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u8a2d\u8a08\u5165\u9580\uff1a\u753b\u9762\u5168\u4f53\u3092\u771f\u3063\u767d\u306b\u3057\u306a\u3044\u305f\u3081\u306e\u8003\u3048\u65b9\u3068\u5b9f\u88c5"},"content":{"rendered":"<p>React \u30a2\u30d7\u30ea\u3092\u904b\u7528\u3057\u3066\u3044\u308b\u3068\u3001\u300c\u753b\u9762\u304c\u771f\u3063\u767d\u306b\u306a\u3063\u305f\u300d\u3068\u3044\u3046\u5831\u544a\u3092\u53d7\u3051\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u539f\u56e0\u306e\u591a\u304f\u306f\u3001<strong>\u63cf\u753b\u4e2d\u306b\u8d77\u304d\u305f\u30a8\u30e9\u30fc\u3092\u3069\u3053\u3067\u3082\u53d7\u3051\u6b62\u3081\u3066\u3044\u306a\u3044\u3053\u3068<\/strong>\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001React \u306e <strong>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\uff08Error Boundary\uff09<\/strong> \u306b\u3064\u3044\u3066\u3001\u4ed5\u7d44\u307f\u30fb\u5b9f\u88c5\u30fb\u7f6e\u304d\u5834\u6240\u306e\u8a2d\u8a08\u30fb\u78ba\u8a8d\u65b9\u6cd5\u307e\u3067\u3092\u5165\u9580\u8005\u5411\u3051\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h2>\u3053\u306e\u8a18\u4e8b\u3067\u308f\u304b\u308b\u3053\u3068<\/h2>\n<ul>\n<li>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u304c\u6355\u307e\u3048\u308b\u30a8\u30e9\u30fc\u3068\u6355\u307e\u3048\u306a\u3044\u30a8\u30e9\u30fc<\/li>\n<li>\u30af\u30e9\u30b9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u3088\u308b\u6700\u5c0f\u5b9f\u88c5<\/li>\n<li><code>react-error-boundary<\/code> \u3092\u4f7f\u3063\u305f\u5b9f\u7528\u7684\u306a\u66f8\u304d\u65b9<\/li>\n<li>\u30a2\u30d7\u30ea\u5168\u4f53\u30fb\u30da\u30fc\u30b8\u30fb\u90e8\u54c1\u306e3\u5c64\u3067\u8003\u3048\u308b\u7f6e\u304d\u5834\u6240\u306e\u8a2d\u8a08<\/li>\n<li>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u3084\u975e\u540c\u671f\u51e6\u7406\u306e\u30a8\u30e9\u30fc\u306e\u6271\u3044\u65b9<\/li>\n<li>React 19 \u3067\u8ffd\u52a0\u3055\u308c\u305f\u30a8\u30e9\u30fc\u901a\u77e5\u30aa\u30d7\u30b7\u30e7\u30f3<\/li>\n<li>\u52d5\u4f5c\u78ba\u8a8d\u3068\u30c6\u30b9\u30c8\u306e\u65b9\u6cd5<\/li>\n<\/ul>\n<h2>\u524d\u63d0\u74b0\u5883<\/h2>\n<ul>\n<li>React 18 \/ 19<\/li>\n<li>TypeScript<\/li>\n<li><code>react-error-boundary<\/code>\uff08v4 \u7cfb\u4ee5\u964d\u3092\u60f3\u5b9a\uff09<\/li>\n<li>\u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306e\u4f8b\u3067\u306f React Router \u3092\u4f7f\u7528<\/li>\n<\/ul>\n<h2>\u306a\u305c\u753b\u9762\u5168\u4f53\u304c\u6d88\u3048\u308b\u306e\u304b<\/h2>\n<p>React \u306f 16 \u4ee5\u964d\u3001\u63cf\u753b\u4e2d\u306e\u30a8\u30e9\u30fc\u304c\u3069\u3053\u3067\u3082\u53d7\u3051\u6b62\u3081\u3089\u308c\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u3001<strong>\u30eb\u30fc\u30c8\u914d\u4e0b\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u30c4\u30ea\u30fc\u3092\u3059\u3079\u3066\u30a2\u30f3\u30de\u30a6\u30f3\u30c8<\/strong>\u3057\u307e\u3059\u3002<\/p>\n<p>\u58ca\u308c\u305f\u72b6\u614b\u306e UI \u3092\u8868\u793a\u3057\u7d9a\u3051\u308b\u3068\u3001\u8aa4\u3063\u305f\u60c5\u5831\u3092\u8868\u793a\u3057\u305f\u308a\u3001\u8aa4\u3063\u305f\u64cd\u4f5c\u3092\u3055\u305b\u305f\u308a\u3059\u308b\u5371\u967a\u304c\u3042\u308a\u307e\u3059\u3002\u305d\u308c\u3092\u907f\u3051\u308b\u305f\u3081\u306e\u8a2d\u8a08\u3067\u3059\u3002\u305f\u3060\u3001\u30e6\u30fc\u30b6\u30fc\u304b\u3089\u898b\u308b\u3068\u30d8\u30c3\u30c0\u30fc\u3082\u30e1\u30cb\u30e5\u30fc\u3082\u6d88\u3048\u3001\u4f55\u3082\u3067\u304d\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u6b21\u306e\u30b3\u30fc\u30c9\u306f\u3001API \u306e\u30ec\u30b9\u30dd\u30f3\u30b9\u306b <code>profile<\/code> \u304c\u306a\u3044\u3060\u3051\u3067 <code>TypeError<\/code> \u306b\u306a\u308a\u3001\u753b\u9762\u5168\u4f53\u304c\u6d88\u3048\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">type User = { profile?: { name: string } };\n\nfunction UserName({ user }: { user: User }) {\n  return &lt;span&gt;{user.profile!.name}&lt;\/span&gt;;\n}<\/pre>\n<h2>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u304c\u6355\u307e\u3048\u308b\u7bc4\u56f2<\/h2>\n<p>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306f\u3001<strong>\u81ea\u5206\u3088\u308a\u4e0b\u306e\u30c4\u30ea\u30fc\u3067\u8d77\u304d\u305f\u6b21\u306e\u30a8\u30e9\u30fc<\/strong>\u3092\u6355\u307e\u3048\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u63cf\u753b\uff08\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0\uff09\u4e2d\u306e\u30a8\u30e9\u30fc<\/li>\n<li>\u30e9\u30a4\u30d5\u30b5\u30a4\u30af\u30eb\u30e1\u30bd\u30c3\u30c9\u5185\u306e\u30a8\u30e9\u30fc<\/li>\n<li>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u5185\u306e\u30a8\u30e9\u30fc<\/li>\n<\/ul>\n<p>\u4e00\u65b9\u3001\u6b21\u306e\u30a8\u30e9\u30fc\u306f\u6355\u307e\u3048\u307e\u305b\u3093\u3002<\/p>\n<table>\n<thead>\n<tr>\n<th>\u6355\u307e\u3048\u306a\u3044\u3082\u306e<\/th>\n<th>\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9<\/td>\n<td><code>onClick<\/code> \u5185\u3067 throw<\/td>\n<\/tr>\n<tr>\n<td>\u975e\u540c\u671f\u51e6\u7406<\/td>\n<td><code>setTimeout<\/code>\u3001Promise\u3001<code>async<\/code> \u95a2\u6570\u5185<\/td>\n<\/tr>\n<tr>\n<td>\u30b5\u30fc\u30d0\u30fc\u30b5\u30a4\u30c9\u30ec\u30f3\u30c0\u30ea\u30f3\u30b0<\/td>\n<td>SSR \u4e2d\u306e\u30a8\u30e9\u30fc<\/td>\n<\/tr>\n<tr>\n<td>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u81ea\u8eab<\/td>\n<td>fallback \u306e\u63cf\u753b\u4e2d\u306e\u30a8\u30e9\u30fc\u306a\u3069<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u306e\u30a8\u30e9\u30fc\u306f\u63cf\u753b\u3092\u58ca\u3055\u306a\u3044\u306e\u3067\u3001\u753b\u9762\u306f\u6d88\u3048\u307e\u305b\u3093\u3002\u305d\u306e\u4ee3\u308f\u308a\u30a8\u30e9\u30fc\u306f\u9ed9\u3063\u3066\u8d77\u304d\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u306f\u4f55\u3082\u4f1d\u308f\u308a\u307e\u305b\u3093\u3002\u3053\u308c\u306f\u5225\u306e\u65b9\u6cd5\u3067\u6271\u3046\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\uff08\u5f8c\u8ff0\uff09\u3002<\/p>\n<h2>\u6700\u5c0f\u5b9f\u88c5\uff1a\u30af\u30e9\u30b9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8<\/h2>\n<p>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306b\u5fc5\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u306b\u306f\u3001\u5bfe\u5fdc\u3059\u308b\u30d5\u30c3\u30af\u304c\u3042\u308a\u307e\u305b\u3093\u3002\u305d\u306e\u305f\u3081\u3001\u81ea\u5206\u3067\u66f8\u304f\u5834\u5408\u306f\u30af\u30e9\u30b9\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">import { Component, type ErrorInfo, type ReactNode } from \"react\";\n\ntype Props = {\n  fallback: ReactNode;\n  children: ReactNode;\n  onError?: (error: unknown, info: ErrorInfo) =&gt; void;\n};\ntype State = { hasError: boolean };\n\nexport class ErrorBoundary extends Component&lt;Props, State&gt; {\n  state: State = { hasError: false };\n\n  static getDerivedStateFromError(): State {\n    return { hasError: true };\n  }\n\n  componentDidCatch(error: unknown, info: ErrorInfo) {\n    this.props.onError?.(error, info);\n  }\n\n  render() {\n    return this.state.hasError ? this.props.fallback : this.props.children;\n  }\n}<\/pre>\n<p>2\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u306e\u5f79\u5272\u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong><code>getDerivedStateFromError<\/code><\/strong>\uff1a\u63cf\u753b\u306e\u6bb5\u968e\u3067\u547c\u3070\u308c\u3001fallback \u3092\u8868\u793a\u3059\u308b\u305f\u3081\u306e state \u3092\u8fd4\u3057\u307e\u3059\u3002\u3053\u3053\u306b\u306f\u526f\u4f5c\u7528\u3092\u66f8\u304d\u307e\u305b\u3093\u3002<\/li>\n<li><strong><code>componentDidCatch<\/code><\/strong>\uff1a\u753b\u9762\u3078\u306e\u53cd\u6620\u304c\u7d42\u308f\u3063\u305f\u6bb5\u968e\u3067\u547c\u3070\u308c\u307e\u3059\u3002\u30ed\u30b0\u9001\u4fe1\u306a\u3069\u306e\u526f\u4f5c\u7528\u306f\u3053\u3061\u3089\u306b\u66f8\u304d\u307e\u3059\u3002<code>info.componentStack<\/code> \u304b\u3089\u3001\u3069\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u8d77\u304d\u305f\u304b\u3092\u8ffd\u3048\u307e\u3059\u3002<\/li>\n<\/ul>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u5b9f\u88c5\u306b\u306f<strong>\u4e00\u5ea6\u30a8\u30e9\u30fc\u306b\u306a\u308b\u3068\u5143\u306b\u623b\u308b\u65b9\u6cd5\u304c\u306a\u3044<\/strong>\u3068\u3044\u3046\u5f31\u70b9\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u52d9\u5411\u3051\uff1areact-error-boundary<\/h2>\n<p>\u518d\u8a66\u884c\u3084\u81ea\u52d5\u30ea\u30bb\u30c3\u30c8\u3092\u81ea\u5206\u3067\u4f5c\u308b\u306e\u306f\u624b\u9593\u304c\u304b\u304b\u308b\u306e\u3067\u3001\u5b9f\u52d9\u3067\u306f <code>react-error-boundary<\/code> \u3092\u4f7f\u3046\u306e\u304c\u4e00\u822c\u7684\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">npm install react-error-boundary<\/pre>\n<pre class=\"lang:default decode:true\">import { ErrorBoundary, type FallbackProps } from \"react-error-boundary\";\n\nfunction ErrorFallback({ error, resetErrorBoundary }: FallbackProps) {\n  const message = error instanceof Error ? error.message : String(error);\n  return (\n    &lt;div role=\"alert\"&gt;\n      &lt;p&gt;\u8868\u793a\u4e2d\u306b\u554f\u984c\u304c\u767a\u751f\u3057\u307e\u3057\u305f\u3002&lt;\/p&gt;\n      {import.meta.env.DEV &amp;&amp; &lt;pre&gt;{message}&lt;\/pre&gt;}\n      &lt;button onClick={resetErrorBoundary}&gt;\u518d\u8a66\u884c&lt;\/button&gt;\n    &lt;\/div&gt;\n  );\n}\n\nexport function UserCard({ user }: { user: User }) {\n  return (\n    &lt;ErrorBoundary\n      FallbackComponent={ErrorFallback}\n      onError={(error, info) =&gt; reportError(error, info.componentStack)}\n    &gt;\n      &lt;UserName user={user} \/&gt;\n    &lt;\/ErrorBoundary&gt;\n  );\n}<\/pre>\n<p>\u203b <code>reportError<\/code> \u306f\u8aac\u660e\u7528\u306e\u4eee\u306e\u95a2\u6570\u3067\u3059\u3002\u76e3\u8996\u30b5\u30fc\u30d3\u30b9\u3092\u4f7f\u3046\u5834\u5408\u306f\u3001\u305d\u306e SDK \u306e API \u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u4e3b\u306a props \u306f\u6b21\u306e\u3068\u304a\u308a\u3067\u3059\u3002<\/p>\n<ul>\n<li><strong><code>FallbackComponent<\/code> \/ <code>fallbackRender<\/code> \/ <code>fallback<\/code><\/strong>\uff1a\u30a8\u30e9\u30fc\u6642\u306b\u8868\u793a\u3059\u308b UI<\/li>\n<li><strong><code>onError<\/code><\/strong>\uff1a\u30a8\u30e9\u30fc\u3092\u6355\u307e\u3048\u305f\u3068\u304d\u306e\u51e6\u7406\uff08\u30ed\u30b0\u9001\u4fe1\uff09<\/li>\n<li><strong><code>onReset<\/code><\/strong>\uff1a\u30ea\u30bb\u30c3\u30c8\u6642\u306e\u5f8c\u59cb\u672b\uff08state \u3084\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u623b\u3059\uff09<\/li>\n<li><strong><code>resetKeys<\/code><\/strong>\uff1a\u914d\u5217\u306e\u5024\u304c\u5909\u308f\u308b\u3068\u81ea\u52d5\u3067\u30ea\u30bb\u30c3\u30c8<\/li>\n<\/ul>\n<h2>\u7f6e\u304d\u5834\u6240\u306e\u8a2d\u8a08\uff1a3\u5c64\u3067\u8003\u3048\u308b<\/h2>\n<p>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306e\u8a2d\u8a08\u3067\u4e00\u756a\u5927\u5207\u306a\u306e\u306f\u3001\u300c<strong>\u3069\u3053\u307e\u3067\u3092\u4e00\u7dd2\u306b\u58ca\u3059\u304b<\/strong>\u300d\u3092\u6c7a\u3081\u308b\u3053\u3068\u3067\u3059\u3002\u6b21\u306e3\u5c64\u3067\u8003\u3048\u308b\u3068\u6574\u7406\u3057\u3084\u3059\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true\">App\n\u251c\u2500 [L1] \u30a2\u30d7\u30ea\u5168\u4f53   \u2026 \u6700\u5f8c\u306e\u7826\u3002\u5168\u753b\u9762\u30a8\u30e9\u30fc\n\u2502   \u251c\u2500 Header \/ Nav\n\u2502   \u2514\u2500 [L2] \u30da\u30fc\u30b8\u5358\u4f4d \u2026 \u30da\u30fc\u30b8\u306e\u4e2d\u8eab\u3060\u3051\u5dee\u3057\u66ff\u3048\n\u2502       \u251c\u2500 [L3] \u90e8\u54c1\u5358\u4f4d \u2026 \u30ab\u30fc\u30c91\u679a\u3060\u3051\u5dee\u3057\u66ff\u3048\n\u2502       \u2514\u2500 [L3] \u90e8\u54c1\u5358\u4f4d<\/pre>\n<h3>L1\uff1a\u30a2\u30d7\u30ea\u5168\u4f53<\/h3>\n<pre class=\"lang:default decode:true\">&lt;ErrorBoundary FallbackComponent={FullPageError}&gt;\n  &lt;App \/&gt;\n&lt;\/ErrorBoundary&gt;<\/pre>\n<p>\u307b\u304b\u306e\u3069\u3053\u306b\u3082\u6355\u307e\u3089\u306a\u304b\u3063\u305f\u30a8\u30e9\u30fc\u306e\u53d7\u3051\u76bf\u3067\u3059\u3002\u3053\u3053\u306b\u30a8\u30e9\u30fc\u304c\u983b\u7e41\u306b\u5c4a\u304f\u5834\u5408\u306f\u3001\u4e0b\u306e\u5c64\u306e\u914d\u7f6e\u304c\u8db3\u308a\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<h3>L2\uff1a\u30da\u30fc\u30b8\u5358\u4f4d<\/h3>\n<pre class=\"lang:default decode:true\">import { Outlet, useLocation } from \"react-router-dom\";\n\nfunction Layout() {\n  const { pathname } = useLocation();\n  return (\n    &lt;&gt;\n      &lt;Header \/&gt;\n      &lt;ErrorBoundary FallbackComponent={PageError} resetKeys={[pathname]}&gt;\n        &lt;Outlet \/&gt;\n      &lt;\/ErrorBoundary&gt;\n    &lt;\/&gt;\n  );\n}<\/pre>\n<p>\u30d8\u30c3\u30c0\u30fc\u3084\u30e1\u30cb\u30e5\u30fc\u3092\u6b8b\u3057\u305f\u307e\u307e\u3001\u30da\u30fc\u30b8\u306e\u4e2d\u8eab\u3060\u3051\u3092\u30a8\u30e9\u30fc\u8868\u793a\u306b\u3067\u304d\u307e\u3059\u3002<code>resetKeys<\/code> \u306b\u30d1\u30b9\u3092\u6e21\u3059\u3068\u3001<strong>\u5225\u306e\u30da\u30fc\u30b8\u3078\u79fb\u52d5\u3057\u305f\u3068\u304d\u306b\u81ea\u52d5\u3067\u30a8\u30e9\u30fc\u8868\u793a\u304c\u89e3\u9664\u3055\u308c\u307e\u3059<\/strong>\u3002\u3053\u308c\u3092\u5165\u308c\u306a\u3044\u3068\u3001\u3069\u306e\u30da\u30fc\u30b8\u306b\u79fb\u52d5\u3057\u3066\u3082\u30a8\u30e9\u30fc\u8868\u793a\u304c\u6b8b\u308a\u307e\u3059\u3002<\/p>\n<h3>L3\uff1a\u90e8\u54c1\u5358\u4f4d<\/h3>\n<pre class=\"lang:default decode:true\">&lt;div className=\"dashboard\"&gt;\n  &lt;ErrorBoundary fallback={&lt;CardError title=\"\u58f2\u4e0a\u63a8\u79fb\" \/&gt;}&gt;\n    &lt;SalesChart \/&gt;\n  &lt;\/ErrorBoundary&gt;\n  &lt;ErrorBoundary fallback={&lt;CardError title=\"\u304a\u77e5\u3089\u305b\" \/&gt;}&gt;\n    &lt;Notices \/&gt;\n  &lt;\/ErrorBoundary&gt;\n&lt;\/div&gt;<\/pre>\n<p>\u30c0\u30c3\u30b7\u30e5\u30dc\u30fc\u30c9\u306e\u30ab\u30fc\u30c9\u3084\u30b0\u30e9\u30d5\u306a\u3069\u3001<strong>\u58ca\u308c\u3066\u3082\u4ed6\u306e\u6a5f\u80fd\u306b\u5f71\u97ff\u3057\u306a\u3044\u90e8\u54c1<\/strong>\u3092\u500b\u5225\u306b\u5305\u307f\u307e\u3059\u3002<\/p>\n<h3>\u5305\u307f\u3059\u304e\u306b\u6ce8\u610f<\/h3>\n<p>\u7d30\u304b\u304f\u5305\u307f\u3059\u304e\u308b\u3068\u3001\u300c\u30d5\u30a9\u30fc\u30e0\u306e\u4e00\u90e8\u3060\u3051\u30a8\u30e9\u30fc\u8868\u793a\u306a\u306e\u306b\u9001\u4fe1\u30dc\u30bf\u30f3\u306f\u62bc\u305b\u308b\u300d\u3068\u3044\u3063\u305f\u5371\u967a\u306a\u72b6\u614b\u304c\u751f\u307e\u308c\u307e\u3059\u3002<strong>\u30e6\u30fc\u30b6\u30fc\u306b\u3068\u3063\u3066\u610f\u5473\u306e\u3042\u308b\u5358\u4f4d<\/strong>\u3067\u533a\u5207\u308b\u3053\u3068\u304c\u57fa\u672c\u3067\u3059\u3002<\/p>\n<h2>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u30fb\u975e\u540c\u671f\u51e6\u7406\u306e\u30a8\u30e9\u30fc<\/h2>\n<p>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u307e\u3067\u5c4a\u304b\u306a\u3044\u30a8\u30e9\u30fc\u306f\u3001\u6b21\u306e2\u3064\u306e\u65b9\u91dd\u3067\u6271\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30e6\u30fc\u30b6\u30fc\u304c\u5bfe\u51e6\u3067\u304d\u308b\u30a8\u30e9\u30fc\u306f\u3001\u305d\u306e\u5834\u3067\u4f1d\u3048\u308b<\/h3>\n<pre class=\"lang:default decode:true\">const [saveError, setSaveError] = useState&lt;string | null&gt;(null);\n\nconst handleSave = async () =&gt; {\n  try {\n    await save(form);\n  } catch {\n    setSaveError(\"\u4fdd\u5b58\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\u6642\u9593\u3092\u304a\u3044\u3066\u518d\u5ea6\u304a\u8a66\u3057\u304f\u3060\u3055\u3044\u3002\");\n  }\n};<\/pre>\n<h3>\u60f3\u5b9a\u5916\u306e\u30a8\u30e9\u30fc\u306f\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u3078\u6e21\u3059<\/h3>\n<pre class=\"lang:default decode:true\">import { useErrorBoundary } from \"react-error-boundary\";\n\nfunction DeleteButton({ id }: { id: string }) {\n  const { showBoundary } = useErrorBoundary();\n\n  const handleClick = async () =&gt; {\n    try {\n      await deleteItem(id);\n    } catch (error) {\n      showBoundary(error);\n    }\n  };\n\n  return &lt;button onClick={handleClick}&gt;\u524a\u9664&lt;\/button&gt;;\n}<\/pre>\n<p><code>showBoundary<\/code> \u3092\u547c\u3076\u3068\u3001\u6700\u3082\u8fd1\u3044\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306e fallback \u306b\u5207\u308a\u66ff\u308f\u308a\u307e\u3059\u3002\u7d9a\u884c\u3059\u308b\u3068\u5371\u967a\u306a\u30a8\u30e9\u30fc\u306e\u898b\u305b\u65b9\u30921\u304b\u6240\u306b\u307e\u3068\u3081\u3089\u308c\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u53d6\u5f97\u30e9\u30a4\u30d6\u30e9\u30ea\u306b\u306f\u3001\u53d6\u5f97\u30a8\u30e9\u30fc\u3092\u63cf\u753b\u6642\u306b throw \u3055\u305b\u3066\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306b\u6e21\u3059\u8a2d\u5b9a\u304c\u3042\u308b\u3082\u306e\u3082\u3042\u308a\u307e\u3059\uff08\u4f8b\uff1aTanStack Query \u306e <code>throwOnError<\/code>\uff09\u3002\u305d\u306e\u5834\u5408\u306f <code>onReset<\/code> \u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u3082\u30ea\u30bb\u30c3\u30c8\u3057\u306a\u3044\u3068\u3001\u518d\u8a66\u884c\u3057\u3066\u3082\u3059\u3050\u306b\u540c\u3058\u30a8\u30e9\u30fc\u306b\u306a\u308a\u307e\u3059\u3002\u8a73\u3057\u304f\u306f\u5404\u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>React 19 \u306e\u30a8\u30e9\u30fc\u901a\u77e5\u30aa\u30d7\u30b7\u30e7\u30f3<\/h2>\n<p>React 19 \u3067\u306f\u3001<code>createRoot<\/code> \u306b\u30a8\u30e9\u30fc\u901a\u77e5\u7528\u306e\u30b3\u30fc\u30eb\u30d0\u30c3\u30af\u3092\u6e21\u305b\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:default decode:true\">import { createRoot } from \"react-dom\/client\";\n\ncreateRoot(document.getElementById(\"root\")!, {\n  onUncaughtError: (error, errorInfo) =&gt; {\n    reportError(error, errorInfo.componentStack);\n  },\n  onCaughtError: (error, errorInfo) =&gt; {\n    reportError(error, errorInfo.componentStack);\n  },\n}).render(&lt;App \/&gt;);<\/pre>\n<ul>\n<li><strong><code>onUncaughtError<\/code><\/strong>\uff1a\u3069\u306e\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306b\u3082\u6355\u307e\u3089\u306a\u304b\u3063\u305f\u30a8\u30e9\u30fc<\/li>\n<li><strong><code>onCaughtError<\/code><\/strong>\uff1a\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u304c\u6355\u307e\u3048\u305f\u30a8\u30e9\u30fc<\/li>\n<\/ul>\n<p>\u30ed\u30b0\u9001\u4fe1\u30921\u304b\u6240\u306b\u96c6\u7d04\u3067\u304d\u308b\u306e\u304c\u5229\u70b9\u3067\u3059\u3002React 18 \u3067\u306f\u4f7f\u3048\u306a\u3044\u306e\u3067\u3001\u5404\u30d0\u30a6\u30f3\u30c0\u30ea\u306e <code>onError<\/code> \u3067\u9001\u4fe1\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u52d5\u4f5c\u78ba\u8a8d\u306e\u65b9\u6cd5<\/h2>\n<h3>\u308f\u3056\u3068\u30a8\u30e9\u30fc\u3092\u8d77\u3053\u3059<\/h3>\n<pre class=\"lang:default decode:true\">function Bomb(): never {\n  throw new Error(\"\u610f\u56f3\u7684\u306a\u30a8\u30e9\u30fc\uff08\u52d5\u4f5c\u78ba\u8a8d\u7528\uff09\");\n}<\/pre>\n<p>\u78ba\u8a8d\u3057\u305f\u3044\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306e\u5185\u5074\u306b\u4e00\u6642\u7684\u306b\u7f6e\u304d\u3001\u6b21\u306e\u70b9\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n<ol>\n<li>fallback \u304c\u60f3\u5b9a\u3057\u305f\u7bc4\u56f2\u3060\u3051\u306b\u8868\u793a\u3055\u308c\u308b<\/li>\n<li>\u300c\u518d\u8a66\u884c\u300d\u3067\u5fa9\u5e30\u3067\u304d\u308b<\/li>\n<li>\u5225\u30da\u30fc\u30b8\u3078\u306e\u9077\u79fb\u3067\u30a8\u30e9\u30fc\u8868\u793a\u304c\u89e3\u9664\u3055\u308c\u308b<\/li>\n<li>\u30ed\u30b0\u9001\u4fe1\u51e6\u7406\u304c\u547c\u3070\u308c\u308b<\/li>\n<\/ol>\n<p>\u958b\u767a\u74b0\u5883\u3067\u306f\u3001\u958b\u767a\u30c4\u30fc\u30eb\u306e\u30a8\u30e9\u30fc\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u304c fallback \u306e\u4e0a\u306b\u91cd\u306a\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u672c\u756a\u30d3\u30eb\u30c9\u3067\u3082\u4e00\u5ea6\u78ba\u8a8d\u3057\u3066\u304a\u304f\u3068\u78ba\u5b9f\u3067\u3059\u3002<\/p>\n<h3>\u81ea\u52d5\u30c6\u30b9\u30c8<\/h3>\n<pre class=\"lang:default decode:true\">import { render, screen } from \"@testing-library\/react\";\nimport { vi, test, expect } from \"vitest\";\n\ntest(\"\u5b50\u3067\u30a8\u30e9\u30fc\u304c\u8d77\u304d\u305f\u3089 fallback \u3092\u8868\u793a\u3059\u308b\", () =&gt; {\n  const spy = vi.spyOn(console, \"error\").mockImplementation(() =&gt; {});\n\n  render(\n    &lt;ErrorBoundary fallback={&lt;p&gt;\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f&lt;\/p&gt;}&gt;\n      &lt;Bomb \/&gt;\n    &lt;\/ErrorBoundary&gt;\n  );\n\n  expect(screen.getByText(\"\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3057\u305f\")).toBeInTheDocument();\n  spy.mockRestore();\n});<\/pre>\n<p>React \u306f\u30a8\u30e9\u30fc\u3092 <code>console.error<\/code> \u306b\u51fa\u529b\u3059\u308b\u305f\u3081\u3001\u30c6\u30b9\u30c8\u4e2d\u3060\u3051\u6291\u5236\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>\u6ce8\u610f\u70b9<\/h2>\n<ul>\n<li><strong>fallback \u3092\u58ca\u3055\u306a\u3044<\/strong>\uff1afallback \u3067\u8d77\u304d\u305f\u30a8\u30e9\u30fc\u306f\u540c\u3058\u30d0\u30a6\u30f3\u30c0\u30ea\u3067\u306f\u6355\u307e\u308a\u307e\u305b\u3093\u3002\u5916\u90e8\u30c7\u30fc\u30bf\u306b\u4f9d\u5b58\u3055\u305b\u305a\u3001\u30b7\u30f3\u30d7\u30eb\u306b\u4fdd\u3061\u307e\u3059\u3002<\/li>\n<li><strong>\u672c\u756a\u3067\u30a8\u30e9\u30fc\u8a73\u7d30\u3092\u51fa\u3055\u306a\u3044<\/strong>\uff1a\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3084\u30b9\u30bf\u30c3\u30af\u306b\u306f\u5185\u90e8\u60c5\u5831\u304c\u542b\u307e\u308c\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/li>\n<li><strong><code>Error<\/code> \u4ee5\u5916\u3082 throw \u3055\u308c\u308b<\/strong>\uff1a<code>instanceof Error<\/code> \u3067\u5224\u5b9a\u3057\u3066\u304b\u3089\u6271\u3044\u307e\u3059\u3002<\/li>\n<li><strong>\u30ea\u30bb\u30c3\u30c8\u6642\u306b\u539f\u56e0\u3092\u53d6\u308a\u9664\u304f<\/strong>\uff1a<code>onReset<\/code> \u3067 state \u3084\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u623b\u3057\u307e\u3059\u3002<\/li>\n<li><strong>\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u306e\u6d41\u5100\u306b\u5f93\u3046<\/strong>\uff1aNext.js \u306a\u3069\u306f\u72ec\u81ea\u306e\u30a8\u30e9\u30fc\u51e6\u7406\u306e\u4ed5\u7d44\u307f\u3092\u6301\u3063\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n<h2>\u307e\u3068\u3081<\/h2>\n<ul>\n<li>\u30a8\u30e9\u30fc\u30d0\u30a6\u30f3\u30c0\u30ea\u306f\u3001\u63cf\u753b\u4e2d\u306e\u30a8\u30e9\u30fc\u3067\u753b\u9762\u5168\u4f53\u304c\u6d88\u3048\u308b\u306e\u3092\u9632\u3050\u4ed5\u7d44\u307f<\/li>\n<li>\u30a4\u30d9\u30f3\u30c8\u30cf\u30f3\u30c9\u30e9\u30fb\u975e\u540c\u671f\u51e6\u7406\u30fbSSR \u306e\u30a8\u30e9\u30fc\u306f\u5bfe\u8c61\u5916\u3002\u305d\u306e\u5834\u3067\u51e6\u7406\u3059\u308b\u304b\u3001<code>showBoundary<\/code> \u3067\u6e21\u3059<\/li>\n<li>\u7f6e\u304d\u5834\u6240\u306f\u300c\u30a2\u30d7\u30ea\u5168\u4f53\uff0f\u30da\u30fc\u30b8\uff0f\u90e8\u54c1\u300d\u306e3\u5c64\u3067\u8003\u3048\u308b<\/li>\n<li><code>react-error-boundary<\/code> \u306e <code>resetKeys<\/code> \u3068 <code>onReset<\/code> \u3067\u3001\u5fc5\u305a\u5fa9\u5e30\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/li>\n<li>\u30ed\u30b0\u306f <code>onError<\/code>\u3001React 19 \u306a\u3089 <code>onCaughtError<\/code> \/ <code>onUncaughtError<\/code> \u306b\u96c6\u7d04\u3059\u308b<\/li>\n<\/ul>\n<p>\u6700\u521d\u306f\u30a2\u30d7\u30ea\u5168\u4f53\u3068\u30da\u30fc\u30b8\u5358\u4f4d\u306e2\u3064\u3092\u7f6e\u304f\u3060\u3051\u3067\u3082\u3001\u969c\u5bb3\u304c\u30e6\u30fc\u30b6\u30fc\u306b\u4e0e\u3048\u308b\u5f71\u97ff\u3092\u304b\u306a\u308a\u5c0f\u3055\u304f\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React \u30a2\u30d7\u30ea\u3092\u904b\u7528\u3057\u3066\u3044\u308b\u3068\u3001\u300c\u753b\u9762\u304c\u771f\u3063\u767d\u306b\u306a\u3063\u305f\u300d\u3068\u3044\u3046\u5831\u544a\u3092\u53d7\u3051\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u539f\u56e0\u306e\u591a\u304f\u306f\u3001\u63cf\u753b\u4e2d\u306b\u8d77\u304d\u305f\u30a8\u30e9\u30fc\u3092\u3069\u3053\u3067\u3082\u53d7\u3051\u6b62\u3081\u3066\u3044\u306a\u3044\u3053\u3068\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":3885,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"sns_share_botton_hide":"","vkExUnit_sns_title":"","_vk_print_noindex":"","sitemap_hide":"","_veu_custom_css":"","veu_display_promotion_alert":"","vkexunit_cta_each_option":"","_lightning_design_setting":[],"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[36],"tags":[64,1161,1188,134,1162,472,389],"class_list":["post-3886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript-memorandum","tag-api","tag-react","tag-1188","tag-134","tag-1162","tag-472","tag-389"],"veu_head_title_object":{"title":"","add_site_title":""},"jetpack_publicize_connections":[],"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/qol-kk.com\/wp2\/wp-content\/uploads\/2026\/11\/20261118-plan108-thumbnail.jpg","_links":{"self":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3886","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/comments?post=3886"}],"version-history":[{"count":1,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3886\/revisions"}],"predecessor-version":[{"id":3892,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/posts\/3886\/revisions\/3892"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media\/3885"}],"wp:attachment":[{"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/media?parent=3886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/categories?post=3886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qol-kk.com\/wp2\/wp-json\/wp\/v2\/tags?post=3886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}