Skip to content

Commit 42abc78

Browse files
committed
add Wrapped.displayName
1 parent 41e300b commit 42abc78

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/ErrorBoundary.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,22 @@ class ErrorBoundary extends Component<Props, State> {
5959
);
6060
}
6161

62-
return children;
62+
return children || null;
6363
}
6464
}
6565

6666
export const withErrorBoundary = (
6767
Component: ComponentType<any>,
6868
FallbackComponent: ComponentType<any>,
6969
onError: Function,
70-
): Function => props => (
71-
<ErrorBoundary FallbackComponent={FallbackComponent} onError={onError}>
72-
<Component {...props} />
73-
</ErrorBoundary>
74-
);
70+
): Function => {
71+
const Wrapped = props => (
72+
<ErrorBoundary FallbackComponent={FallbackComponent} onError={onError}>
73+
<Component {...props} />
74+
</ErrorBoundary>
75+
);
76+
Wrapped.displayName = `WithErrorBoundary(${getDisplayName(Component)})`;
77+
return Wrapped;
78+
};
7579

7680
export default ErrorBoundary;

0 commit comments

Comments
 (0)