@times-components/error-view

2.6.42 • Public • Published

Error View

The error view package is a React Error Boundary. From the React documentation itself:

Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed. Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.

This package provides an ErrorView wrapper component that takes a render prop as a direct child of the component. This function returns three possible values which can be used to handle the enclosed child components:

  • error - the error that was returned
  • hasError - boolean, did the component error
  • onError - a function that handles errors and triggers the error view components error handling

Contributing

Please read CONTRIBUTING.md before contributing to this package

Running the code

Please see our main README.md to get the project running locally

Development

The code can be formatted and linted in accordance with the agreed standards.

yarn fmt
yarn lint

Testing

This package uses yarn (latest) to run unit tests on each platform with jest.

yarn test:web

Visit the official storybook to see our available error view templates.

Package Sidebar

Install

npm i @times-components/error-view

Weekly Downloads

9,579

Version

2.6.42

License

BSD-3-Clause

Unpacked Size

146 kB

Total Files

8

Last publish

Collaborators

  • marcincuber
  • newsuk
  • news-tools