{"id":16482659,"url":"https://github.com/mfix22/eitherx","last_synced_at":"2025-08-23T01:43:04.759Z","repository":{"id":25990151,"uuid":"107044895","full_name":"mfix22/eitherx","owner":"mfix22","description":":pill: Your go-to, prescribed, error-boundary component for React","archived":false,"fork":false,"pushed_at":"2022-12-09T08:19:48.000Z","size":236,"stargazers_count":91,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-14T16:49:59.485Z","etag":null,"topics":["binary","boundaries","either","error-boundaries","express","render-prop","wrapper-component"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eitherx","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mfix22.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-15T20:02:37.000Z","updated_at":"2024-11-21T06:29:41.000Z","dependencies_parsed_at":"2023-01-14T03:49:24.253Z","dependency_job_id":null,"html_url":"https://github.com/mfix22/eitherx","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfix22%2Feitherx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfix22%2Feitherx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfix22%2Feitherx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mfix22%2Feitherx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mfix22","download_url":"https://codeload.github.com/mfix22/eitherx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826783,"owners_count":20354220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary","boundaries","either","error-boundaries","express","render-prop","wrapper-component"],"created_at":"2024-10-11T13:11:36.018Z","updated_at":"2025-03-16T18:31:40.830Z","avatar_url":"https://github.com/mfix22.png","language":"JavaScript","readme":"# `\u003cEitherx /\u003e`\n\n:pill: Super simple, reusable either-or [error boundaries][react-error-docs] for React. Your go-to, prescribed, error-boundary component.\n\n[![bundle size](https://badgen.net/bundlephobia/min/eitherx)](https://bundlephobia.com/result?p=eitherx)\n[![tested with jest](https://img.shields.io/badge/tested_with-jest-99424f.svg)](https://github.com/facebook/jest)\n[![PRs welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com)\n[![MIT License](https://img.shields.io/github/license/mfix22/eitherx.svg)](https://github.com/mfix22/eitherx/blob/master/LICENSE)\n\n## Usage\n\n```shell\n$ npm i --save eitherx\n```\n\n```javascript\nimport Either from 'eitherx'\n\n// Wrapper-component Style\n\u003cEither\u003e\n  {/* Either . . . */}\n  \u003cp\u003e\"Happy Child 😄\"\u003c/p\u003e\n  {/* Or . . . */}\n  \u003cp\u003e\"Error child ☹️ (but at least your UI is happy)\"\u003c/p\u003e\n\u003c/Either\u003e\n\n// OR use the `render` and `catchError` props\n\n// Render-prop Style\n\u003cEither\n  render={() =\u003e (\u003cp\u003e\"Happy Child 😄\"\u003c/p\u003e)}\n  catchError={({ error }) =\u003e (\n    \u003cdiv\u003e\n      \u003cp\u003e{`Error: ${error}`}\u003c/p\u003e\n    \u003c/div\u003e\n  )}\n/\u003e\n```\n\n### Wrapper Component Style\n\n`Eitherx` either renders the first child component, unless an error occurred while rendering, then the second child is rendered. Easy enough 😄.\n\nIf you do not pass a second child, and an error occurs, `null` will be return to React to render.\n\n### Render-prop Style\n\nUsing this style, you must pass a function for both `render` _and_ `catchError`. If an error occurs, the component\nreturned from `catchError` will be rendered. Otherwise `Eitherx` will render the component returned from `render`.\n\nThe `catchError` function receives an object with the field `error` set, both of which are passed directly from\n[React Error Boundaries][react-error-docs-target].\n\n[react-error-docs]: https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html\n[react-error-docs-target]: https://reactjs.org/blog/2017/07/26/error-handling-in-react-16.html#introducing-error-boundaries\n\n### Handling Errors\n\nWith either style, you can pass an `handleError` callback prop to add additional error handling, logging, etc.\n\n##### Example\n\n```javascript\n\u003cEitherx\n  handleError={({ error, info }) =\u003e {\n    console.log(info)\n    console.error(error)\n  }}\n  render={() =\u003e \u003cComponent\u003e\"Render Prop\"\u003c/Component\u003e}\n  catchError={() =\u003e \u003cp\u003e\"Catch Prop\"\u003c/p\u003e}\n/\u003e\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfix22%2Feitherx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmfix22%2Feitherx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmfix22%2Feitherx/lists"}