{"id":"chriscerie/react-error-boundary","name":"react-error-boundary","scope":"chriscerie","platform":"roblox","description":"A robust error boundary library for Lua React.","version":"0.2.0","latest":"0.2.0","versions":["0.1.0","0.2.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"jsdotlua/collections":{"version":"^1.2.0","alias":"Collections"},"jsdotlua/luau-polyfill":{"version":"^1.2.0","alias":"LuauPolyfill"},"jsdotlua/react":{"version":"^17.0.0","alias":"React"},"jsdotlua/react-roblox":{"version":"^17.0.0","alias":"ReactRoblox"},"csqrl/sift":{"version":"~0.0.0","alias":"Sift"},"roblox/testez":{"version":"^0.4.0","alias":"TestEZ"}},"integrity":"d6ee53307f75c119b14a8905afed0fd8e6207f51d1da811ff419ab8f6d308fcf","likes":0,"downloads":0,"install":"forest install chriscerie/react-error-boundary","url":"https://forest.dev/p/roblox/chriscerie/react-error-boundary","files":"https://api.forest.dev/ai/package/roblox/chriscerie/react-error-boundary/files","readme":"<a href=\"https://www.chrisc.dev/react-error-boundary/\">\r\n  <p align=\"center\">\r\n    <img src=\"https://i.imgur.com/1Ta6WRv.png\" width=\"200\" />\r\n  </p>\r\n</a>\r\n\r\n<h1 align=\"center\">react-error-boundary</h1>\r\n<h3 align=\"center\">A robust error boundary library for <a href=\"https://github.com/grilme99/CorePackages\">Lua React</a>.</h3>\r\n\r\n<br>\r\n\r\n<div align=\"center\">\r\n  <a href=\"https://github.com/chriscerie/react-error-boundary/actions/workflows/docs.yml\">\r\n    <img src=\"https://github.com/chriscerie/react-error-boundary/workflows/docs/badge.svg\" alt=\"Deploy Docs Status\"/>\r\n  </a>\r\n</div>\r\n\r\n<br>\r\n\r\n## Why react-error-boundary\r\n\r\nBy design, React unmounts the entire tree when it encounters an unhandled error. This leaves the application in an ususable state unless the user refreshes the application. In the context of a video game, the player would need to leave and rejoin the game. Error boundaries provide a way to recover from errors to greatly improve user experience.\r\n\r\n### Use cases\r\n\r\n- Rendering fallback components upon errors (e.g., error screen)\r\n- Reverting state to a known good state\r\n- Retrying render with reverted state\r\n- Logging errors in an external database\r\n\r\n## Installation\r\n\r\n### Wally\r\n\r\nAdd the latest version of react-error-boundary to your wally.toml (e.g., `ReactErrorBoundary = \"chriscerie/react-error-boundary@<version>\"`)\r\n\r\n## Getting Started\r\n\r\nGetting started with react-error-boundary is simple. First, create a fallback component.\r\n\r\n```lua\r\nlocal e = React.createElement\r\n\r\nlocal Fallback: React.FC<ReactErrorBoundary.FallbackProps> = function(_props)\r\n    return e(\"TextLabel\", {\r\n        AnchorPoint = Vector2.new(0.5, 0.5),\r\n        Size = UDim2.fromScale(0.5, 0.5),\r\n        Position = UDim2.fromScale(0.5, 0.5),\r\n        Text = \"An error was encountered!.\",\r\n    })\r\nend\r\n```\r\n\r\nNext, in your app, wrap an `ErrorBoundary` where needed.\r\n\r\n```lua\r\nlocal App: React.FC<{}> = function(_props)\r\n    return e(ReactErrorBoundary.ErrorBoundary, {\r\n        FallbackComponent = Fallback,\r\n    }, {\r\n        ComponentThatMightError = e(ComponentThatMightError),\r\n    })\r\nend\r\n```\r\n\r\nNow when `ComponentThatMightError` or any of its descendant errors, the error boundary will catch it and render the fallback component. When an error is encountered somewhere in your app, the nearest `ErrorBoundary` will catch and handle it. You don't need to wrap every component in an `ErrorBoundary`. Consider the [granularity of error boundaries](https://aweary.dev/fault-tolerance-react/) and where it makes sense to display an error message or revert states.\r\n\r\nThis was a very basic example. In a real application, you might want the fallback component to render a \"go back\" button that reverts state, or you might want to do that immediately after encountering an error. More advanced usage is detailed in react-error-boundary's official [documentation](https://www.chrisc.dev/react-error-boundary/).\r\n\r\n## License\r\n\r\n`react-error-boundary` is available under the MIT license. See [LICENSE](LICENSE) for details.\r\n","readmeTruncated":false}