1.0.4 • Published 4 years ago

use-error-boundary-hook v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

use-error-boundary-hook

npm version license

A React hook that allows you to use an error boundary in functional components.

Install

npm i use-errour-boundary-hook

Example

import useErrorBoundary from 'use-error-boundary-hook';

function MyComponent(props) {
	const [Try, Catch] = useErrorBoundary();

	return (
		<Try>
			This is my content.
		</Try>
		<Catch>
			Fallback content!
		</Catch>
	);
}

The hook returns more than just the Try and Catch component:

const [Try, Catch, { hasError, error, errorInfo }] = useErrorBoundary();
PropertyType
hasErrorBooleantrue if an error has been caught
errorErrorObject or nullSee React Docs
errorInfoObject or nullSee React Docs
1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago