Skip to content

Commit fdfa96b

Browse files
committed
fix: error boundary use arrow fun case parameter list error
1 parent b323179 commit fdfa96b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ErrorBoundary.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,16 @@ export class ErrorBoundary extends Component<
2121
PropsWithRef<PropsWithChildren<ErrorBoundaryProps>>,
2222
ErrorBoundaryState
2323
> {
24-
state = initialState;
24+
constructor(props: ErrorBoundaryProps ){
25+
super(props);
26+
this.state = initialState;
27+
}
2528

2629
static getDerivedStateFromError(error: Error) {
2730
return { didCatch: true, error };
2831
}
2932

30-
resetErrorBoundary = (...args: any[]) => {
33+
resetErrorBoundary(...args: any[]) {
3134
const { error } = this.state;
3235

3336
if (error !== null) {
@@ -81,7 +84,7 @@ export class ErrorBoundary extends Component<
8184
if (didCatch) {
8285
const props: FallbackProps = {
8386
error,
84-
resetErrorBoundary: this.resetErrorBoundary,
87+
resetErrorBoundary: this.resetErrorBoundary.bind(this),
8588
};
8689

8790
if (isValidElement(fallback)) {
@@ -103,7 +106,7 @@ export class ErrorBoundary extends Component<
103106
value: {
104107
didCatch,
105108
error,
106-
resetErrorBoundary: this.resetErrorBoundary,
109+
resetErrorBoundary: this.resetErrorBoundary.bind(this),
107110
},
108111
},
109112
childToRender

0 commit comments

Comments
 (0)