react-error-boundaries
Advanced tools
Comparing version
{ | ||
"name": "react-error-boundaries", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "React HOC for error boundaries.", | ||
@@ -35,6 +35,5 @@ "main": "dist/commonjs/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0", | ||
"react-error-boundaries": "^1.0.6" | ||
"peerDevDependencies": { | ||
"react": "^16.0.0", | ||
"react-dom": "^16.0.0" | ||
}, | ||
@@ -54,4 +53,6 @@ "devDependencies": { | ||
"webpack": "^3.10.0", | ||
"webpack-dev-server": "^2.9.7" | ||
"webpack-dev-server": "^2.9.7", | ||
"react": "^16.2.0", | ||
"react-dom": "^16.2.0" | ||
} | ||
} |
@@ -34,6 +34,6 @@ # react-error-boundaries | ||
- ErrorBoundary: React container component to handler error | ||
- withErrorHandler: React HOC to customize the errorCallback function and FallbackComponent | ||
- errorHandlerDecorator: By this, you can use error boundary as ES7 decorator | ||
- FallbackView: The default fallback component, show when error occur. props: { error: Objec, errorInfo: Object, closeErrorModal: Function } | ||
- **ErrorBoundary**: React container component to handler error | ||
- **withErrorHandler**: React HOC to customize the errorCallback function and FallbackComponent | ||
- **errorHandlerDecorator**: By this, you can use error boundary as ES7 decorator | ||
- **FallbackView**: The default fallback component, show when error occur. props: `{ error: Objec, errorInfo: Object, closeErrorModal: Function }` | ||
@@ -58,4 +58,9 @@ Use as a component container: | ||
And you can handle errors by providing an onError callback: | ||
And you can handle errors by providing an onError callback, and customize the FallbackComponent by providing a Component. | ||
> FallbackComponent will receive props: | ||
- closeErrorModal: Function, call when click close button | ||
- error: An error that has been thrown. | ||
- errorInfo: An object with componentStack key. The property has information about component stack during thrown error. | ||
```js | ||
@@ -74,3 +79,3 @@ // import first | ||
return ( | ||
<ErrorBoundary onError={onError}> | ||
<ErrorBoundary onError={onError} FallbackComponent={YourFallbackView}> | ||
<YourComponents /> | ||
@@ -116,3 +121,3 @@ </ErrorBoundary> | ||
In HOC way, you can also customize the FallbackComponent for better appearance: | ||
You can also customize the FallbackComponent in HOC way: | ||
@@ -119,0 +124,0 @@ ```js |
100252
0.38%0
-100%163
3.16%15
15.38%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed