{"name":"react-error-boundary","version":"6.0.3","keywords":["react","reactjs","virtual","window","windowed","list","scrolling","infinite","virtualized","table","grid","spreadsheet"],"author":{"name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"},"license":"MIT","_id":"react-error-boundary@6.0.3","maintainers":[{"name":"kentcdodds","email":"me@kentcdodds.com"},{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"}],"contributors":[{"url":"https://github.com/bvaughn/","name":"Brian Vaughn","email":"brian.david.vaughn@gmail.com"}],"homepage":"https://react-error-boundary-lib.vercel.app/","bugs":{"url":"https://github.com/bvaughn/react-error-boundary/issues"},"dist":{"shasum":"e84bb9e67e692f83d3ea0fc35612db68d7d804c6","tarball":"http://registry-npm.ywwl.com/react-error-boundary/download/react-error-boundary-6.0.3.tgz","fileCount":8,"integrity":"sha512-5guqn2UYpCFjE8UDMA8J7Kke+YSGBFrKQRJb3XdcaGZXYINZfQXgBt3ifY6MvjkN7QROc5A8zclyoSCwrcRUKw==","signatures":[{"sig":"MEUCICSR9jjXbF5WmDs++7KCCuzTXo8daLzmR+hkjmEV6aI/AiEApLDnOQxMvGQ2JOWECpP49RuCSws1tvJidNCMpvY5DHU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":44046,"size":10745,"noattachment":false,"key":"/react-error-boundary/-/react-error-boundary-6.0.3.tgz"},"main":"dist/react-error-boundary.cjs","type":"module","types":"dist/react-error-boundary.d.ts","module":"dist/react-error-boundary.js","gitHead":"186ae40419aed3c1ee3a36a717e279ace9e188bb","scripts":{"dev":"vite","tsc":"tsc -b","lint":"eslint .","test":"vitest","build":"pnpm run build:lib && pnpm run build:docs","compile":"pnpm run compile:docs && pnpm run compile:examples","preview":"vite preview","test:ci":"vitest run","prettier":"prettier --write \"**/*.{css,html,js,json,jsx,ts,tsx}\"","build:lib":"TARGET=lib vite build","build:docs":"TARGET=docs vite build","prerelease":"rm -rf dist && pnpm run build:lib","test:debug":"vitest --inspect-brk=127.0.0.1:3000 --no-file-parallelism","prettier:ci":"prettier --check \"**/*.{css,html,js,json,jsx,ts,tsx}\"","compile:docs":"tsx ./scripts/compile-docs","compile:examples":"tsx ./scripts/compile-examples","dev:integrations":"pnpm -C integrations/vite/ run dev","compress:og-image":"tsx ./scripts/compress-og-image"},"_npmUser":{"name":"brianvaughn","email":"briandavidvaughn@gmail.com"},"repository":{"url":"git+https://github.com/bvaughn/react-error-boundary.git","type":"git"},"_npmVersion":"11.4.2","description":"Simple reusable React error boundary component","directories":{},"lint-staged":{"**/*":"prettier --write --ignore-unknown"},"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","clsx":"^2.1.1","sirv":"^3.0.2","vite":"^7.0.4","bytes":"^3.1.2","husky":"^9.1.7","jsdom":"^26.1.0","react":"^19.2.3","sharp":"^0.34.5","eslint":"^9.30.1","marked":"^16.4.1","terser":"^5.43.1","vitest":"^3.2.4","csstype":"^3.1.3","globals":"^16.3.0","postcss":"^8.5.6","ts-node":"^10.9.2","zustand":"^5.0.7","prettier":"3.6.2","react-dom":"^19.2.3","@eslint/js":"^9.30.1","typescript":"~5.8.3","@types/node":"^24.2.0","compression":"^1.8.1","lint-staged":"^16.1.4","markdown-it":"^14.1.0","tailwindcss":"^4.1.11","@types/bytes":"^3.1.5","@types/react":"^19.1.8","@types/sharp":"^0.32.0","tailwind-merge":"^3.3.1","ts-blank-space":"^0.6.2","react-lib-tools":"^0.0.30","vite-plugin-dts":"^4.5.4","@heroicons/react":"^2.2.0","@types/react-dom":"^19.2.3","react-router-dom":"^7.6.3","vite-plugin-svgr":"^4.3.0","@headlessui/react":"^2.2.4","@tailwindcss/vite":"^4.1.11","typescript-eslint":"^8.35.1","@types/compression":"^1.8.1","@types/markdown-it":"^14.1.2","react-error-boundary":"^6.0.0","rollup-plugin-terser":"^7.0.2","@tailwindplus/elements":"^1.0.5","@testing-library/react":"^16.3.0","typescript-json-schema":"^0.65.1","vitest-fail-on-console":"^0.10.1","@headlessui/tailwindcss":"^0.2.2","react-docgen-typescript":"^2.4.0","@vitejs/plugin-react-swc":"^3.10.2","rollup-plugin-visualizer":"^6.0.3","@testing-library/jest-dom":"^6.6.4","eslint-plugin-react-hooks":"^5.2.0","rollup-preserve-directives":"^1.1.3","@testing-library/user-event":"^14.6.1","eslint-plugin-react-refresh":"^0.4.20","prettier-plugin-tailwindcss":"^0.7.1","@csstools/postcss-oklab-function":"^4.0.11"},"peerDependencies":{"react":"^18.0.0 || ^19.0.0"},"_npmOperationalInternal":{"tmp":"tmp/react-error-boundary_6.0.3_1767910299314_0.4482220065995308","host":"s3://npm-registry-packages-npm-production"},"readme":"<img src=\"https://react-error-boundary-lib.vercel.app/og.png\" alt=\"react-error-boundary logo\" width=\"400\" height=\"210\" />\n\n`react-error-boundary`: Reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component. Supports all React renderers (including React DOM and React Native).\n\n### If you like this project, 🎉 [become a sponsor](https://github.com/sponsors/bvaughn/) or ☕ [buy me a coffee](http://givebrian.coffee/)\n\n> [!NOTE]\n> Projects using framework or runtimes that don't support ES Modules should use version 5 of this library.\n\n## Getting started\n\n```sh\n# npm\nnpm install react-error-boundary\n\n# pnpm\npnpm add react-error-boundary\n\n# yarn\nyarn add react-error-boundary\n```\n\n## Documentation\n\nRead the [react-error-boundary docs](https://react-error-boundary-lib.vercel.app/) for examples, API reference, and troubleshooting. The docs also include a [frequently asked questions guide](https://react-error-boundary-lib.vercel.app/common-questions).\n\n## Quick start\n\nWrap an `ErrorBoundary` around the part of the tree where you want to show a fallback UI if rendering fails. Your fallback can call `resetErrorBoundary` to clear the error and retry rendering:\n\n```tsx\n\"use client\";\n\nimport { ErrorBoundary, getErrorMessage } from \"react-error-boundary\";\n\nexport default function App() {\n  return (\n    <ErrorBoundary\n      fallbackRender={({ error, resetErrorBoundary }) => (\n        <div role=\"alert\">\n          <p>Something went wrong:</p>\n          <pre>{getErrorMessage(error)}</pre>\n          <button onClick={resetErrorBoundary}>Try again</button>\n        </div>\n      )}\n      onError={(error, info) => {\n        // Log the error to your error reporting service\n      }}\n      onReset={() => {\n        // Reset any state that may have caused the error\n      }}\n    >\n      {/* Components protected by this boundary */}\n    </ErrorBoundary>\n  );\n}\n```\n\n## What errors are caught?\n\nThis package is built on top of React [error boundaries](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary), so it follows React's rules for what errors are caught.\n\nError boundaries catch errors thrown while rendering the tree below them.\n\nError boundaries do not catch errors thrown during:\n\n- Server side rendering\n- Event handlers\n- Errors thrown in the error boundary itself\n- Async code that runs after rendering, like `setTimeout` callbacks or unresolved promises\n\n## Event handler and async errors\n\nFor event handler errors and async callback errors:\n\n- Use `useErrorBoundary` to pass caught errors to the nearest boundary.\n- In React 19, `useTransition` Actions can be an alternative: errors thrown from a function passed to the returned `startTransition` function are caught by the nearest boundary.\n\n```tsx\n\"use client\";\n\nimport { useTransition } from \"react\";\nimport { ErrorBoundary } from \"react-error-boundary\";\n\nfunction AddCommentContainer() {\n  return (\n    <ErrorBoundary fallback={<p>Could not add comment</p>}>\n      <AddCommentButton />\n    </ErrorBoundary>\n  );\n}\n\nfunction AddCommentButton() {\n  const [isPending, startTransition] = useTransition();\n\n  function handleClick() {\n    startTransition(async () => {\n      await addComment();\n    });\n  }\n\n  return (\n    <button disabled={isPending} onClick={handleClick}>\n      {isPending ? \"Adding...\" : \"Add comment\"}\n    </button>\n  );\n}\n```\n\n## API\n\n### ErrorBoundary\n\n<!-- ErrorBoundary:description:begin -->\nA reusable React [error boundary](https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary) component.\nWrap this component around other React components to \"catch\" errors and render a fallback UI.\n\nCatches errors thrown while rendering the tree below it.\n\nDoes not catch errors thrown during:\n- Server side rendering\n- Event handlers\n- Errors thrown in the error boundary itself\n- Async code that runs after rendering, like `setTimeout` callbacks or unresolved promises\n\nEvent handler and async errors:\n\n- Use `useErrorBoundary` to pass caught errors to the nearest boundary\n- In React 19, errors thrown from a function passed to the `startTransition` function returned by `useTransition`\n  are caught by the nearest boundary\n\nℹ️ The component provides several ways to render a fallback: `fallback`, `fallbackRender`, and `FallbackComponent`.\nRefer to the documentation to determine which is best for your application.\n\nℹ️ This is a **client component**. You can only pass props to it that are serializable or use it in files that have a `\"use client\";` directive.\n<!-- ErrorBoundary:description:end -->\n\n#### Required props\n\n<!-- ErrorBoundary:required-props:begin -->\nNone\n<!-- ErrorBoundary:required-props:end -->\n\n#### Optional props\n\n<!-- ErrorBoundary:optional-props:begin -->\n\n<table>\n  <thead>\n    <tr>\n      <th>Name</th>\n      <th>Description</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <td>onError</td>\n      <td><p>Optional callback to enable e.g. logging error information to a server.\n@param error Value that was thrown; typically an instance of <code>Error</code>\n@param info React &quot;component stack&quot; identifying where the error was thrown</p>\n</td>\n    </tr>\n    <tr>\n      <td>onReset</td>\n      <td><p>Optional callback to be notified when an error boundary is reset so React can retry the failed render.</p>\n</td>\n    </tr>\n    <tr>\n      <td>resetKeys</td>\n      <td><p>When changed, these keys will reset a triggered error boundary.\nThis can be useful when an error condition may be tied to some specific state (that can be uniquely identified by key).\nSee the documentation for examples of how to use this prop.</p>\n</td>\n    </tr>\n    <tr>\n      <td>fallback</td>\n      <td><p>Static content to render in place of an error if one is thrown.</p>\n<pre><code class=\"language-tsx\">&lt;ErrorBoundary fallback={&lt;div className=&quot;text-red&quot;&gt;Something went wrong&lt;/div&gt;} /&gt;\n</code></pre>\n</td>\n    </tr>\n    <tr>\n      <td>FallbackComponent</td>\n      <td><p>React component responsible for returning a fallback UI based on a thrown value.</p>\n<pre><code class=\"language-tsx\">&lt;ErrorBoundary FallbackComponent={Fallback} /&gt;\n</code></pre>\n</td>\n    </tr>\n    <tr>\n      <td>fallbackRender</td>\n      <td><p><a href=\"https://react.dev/reference/react/Children#calling-a-render-prop-to-customize-rendering\">Render prop</a> function responsible for returning a fallback UI based on a thrown value.</p>\n<pre><code class=\"language-tsx\">&lt;ErrorBoundary fallbackRender={({ error, resetErrorBoundary }) =&gt; &lt;div&gt;...&lt;/div&gt;} /&gt;\n</code></pre>\n</td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- ErrorBoundary:optional-props:end -->\n\n# FAQ\n## `ErrorBoundary` cannot be used as a JSX component\nThis error can be caused by a version mismatch between [react](https://npmjs.com/package/react) and [@types/react](https://npmjs.com/package/@types/react). To fix this, ensure that both match exactly, e.g.:\n\nIf using NPM:\n```json\n{\n  ...\n  \"overrides\": {\n    \"@types/react\": \"17.0.60\"\n  },\n  ...\n}\n```\n\nIf using Yarn:\n```json\n{\n  ...\n  \"resolutions\": {\n    \"@types/react\": \"17.0.60\"\n  },\n  ...\n}\n```\n\n---\n\n[This blog post](https://kentcdodds.com/blog/use-react-error-boundary-to-handle-errors-in-react) shows more examples of how this package can be used, although it was written for the [version 3 API](https://github.com/bvaughn/react-error-boundary/releases/tag/v3.1.4).\n","publish_time":1767910299462,"_cnpm_publish_time":1767910299462,"dist-tags":{"latest":"6.1.6"}}