Skip to content

Commit ea0dbd5

Browse files
committed
1.2.0 - onError called with HOC 'this'
1 parent 0edfc1c commit ea0dbd5

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ import ErrorBoundary from 'react-error-boundary';
1313
</ErrorBoundary>
1414
```
1515

16-
You can also use it as a HOC:
17-
18-
```jsx
19-
import {withErrorBoundary} from 'react-error-boundary';
20-
21-
const ComponentWithErrorBoundary = withErrorBoundary(YourComponent);
22-
```
23-
2416
You can react to errors (eg for logging) by providing an `onError` callback:
2517

2618
```jsx
@@ -45,4 +37,16 @@ const MyFallbackComponent = ({ componentStack, error }) => (
4537
<ErrorBoundary FallbackComponent={MyFallbackComponent}>
4638
<ComponentThatMayError />
4739
</ErrorBoundary>
40+
```
41+
42+
You can also use it as a HOC:
43+
44+
```jsx
45+
import {withErrorBoundary} from 'react-error-boundary';
46+
47+
const ComponentWithErrorBoundary = withErrorBoundary(
48+
ComponentToDecorate: Element<any>,
49+
CustomFallbackComponent: ?Element<any>,
50+
onErrorHandler: ?(error: Error, componentStack: string) => void,
51+
);
4852
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-error-boundary",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Sample reusable React error boundary component for React 16+",
55
"files": [
66
"dist"

src/ErrorBoundary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ErrorBoundary extends Component<Props, State> {
3535

3636
if (typeof onError === 'function') {
3737
try {
38-
onError(error, info ? info.componentStack : '');
38+
onError.call(this, error, info ? info.componentStack : "");
3939
} catch (ignoredError) {}
4040
}
4141

0 commit comments

Comments
 (0)