{"id":13462219,"url":"https://github.com/Fundebug/fundebug-react-demo","last_synced_at":"2025-03-25T01:31:50.836Z","repository":{"id":153051444,"uuid":"155203225","full_name":"Fundebug/fundebug-react-demo","owner":"Fundebug","description":"演示React项目如何接入Fundebug错误监控服务","archived":false,"fork":false,"pushed_at":"2019-09-10T22:50:04.000Z","size":161,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T11:10:50.068Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fundebug.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-29T11:50:44.000Z","updated_at":"2020-12-18T14:19:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"f95d1fe9-c7af-4ed0-869b-ca9fcd5a0ea4","html_url":"https://github.com/Fundebug/fundebug-react-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fundebug%2Ffundebug-react-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fundebug%2Ffundebug-react-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fundebug%2Ffundebug-react-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fundebug%2Ffundebug-react-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fundebug","download_url":"https://codeload.github.com/Fundebug/fundebug-react-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245381993,"owners_count":20606139,"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":[],"created_at":"2024-07-31T12:00:42.441Z","updated_at":"2025-03-25T01:31:50.548Z","avatar_url":"https://github.com/Fundebug.png","language":"JavaScript","readme":"## [Fundebug](https://www.fundebug.com/)监控[React](https://facebook.github.io/react/)应用错误\n\n### 安装[fundebug-javascript](https://www.npmjs.com/package/fundebug-javascript)\n\n```js\nnpm install fundebug-javascript\n```\n\n### 配置apikey\n\n```js\nvar fundebug=require(\"fundebug-javascript\");\nfundebug.apikey=\"API-KEY\"\n```\n\n其中，获取**apikey**需要[免费注册](https://www.fundebug.com/team/create)帐号并且[创建项目](https://www.fundebug.com/project/create)。\n\n### 配置ErrorBoundary\n\nReact 16之前的版本，无需额外配置。\n\n对于React 16及其以后的版本，需要在**src/index.js**中进行额外配置：\n\n```javascript\nclass ErrorBoundary extends React.Component {\n  constructor(props) {\n    super(props);\n    this.state = { hasError: false };\n  }\n\n  componentDidCatch(error, info) {\n    this.setState({ hasError: true });\n    // 将component中的报错发送到Fundebug\n    fundebug.notifyError(error, {\n      metaData: {\n        info: info\n      }\n    });\n  }\n\n  render() {\n    if (this.state.hasError) {\n      return null\n      // 也可以在出错的component处展示出错信息\n      // return \u003ch1\u003e出错了!\u003c/h1\u003e;\n    }\n    return this.props.children;\n  }\n}\n\nReactDOM.render( \u003c ErrorBoundary \u003e \u003c App / \u003e \u003c /ErrorBoundary\u003e, document.getElementById('root'));\n```\n\n### 参考\n\n- [Fundebug文档 - 监控React](https://docs.fundebug.com/notifier/javascript/framework/react.html)","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFundebug%2Ffundebug-react-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFundebug%2Ffundebug-react-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFundebug%2Ffundebug-react-demo/lists"}