项目作者: hamlim

项目描述 :
An unopinionated `` React component for React 16+.
高级语言: JavaScript
项目地址: git://github.com/hamlim/react-error-boundary.git
创建时间: 2017-08-12T01:34:43Z
项目社区:https://github.com/hamlim/react-error-boundary

开源协议:

下载


React-Error-Boundary 🚯

An unopinionated <ErrorBoundary ></ErrorBoundary> React component for React 16+.

  1. <div>
  2. <ErrorBoundary
  3. onError={logError}
  4. >
  5. {error => error
  6. ? (
  7. <h1>Oh no an error occurred!</h1>
  8. )
  9. : (
  10. <Application ></Application>
  11. )
  12. }
  13. </ErrorBoundary>
  14. </div>

Props:

  • onError method called after <ErrorBoundary ></ErrorBoundary> catches an error.
    • type function
    • Called with one argument, the error object thrown
  • children function called inside render
    • Called with the error object, will be null initially
    • This is the only thing returned from render, so you have full control over rendering