The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/components/withErrorBoundary.tsx

18 lines
597 B

import type { ComponentType, ReactNode, ComponentProps } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
function withErrorBoundary<T extends object>(Component: ComponentType<T>, fallback: ReactNode = null) {
const WrappedComponent = function (props: ComponentProps<typeof Component>) {
return (
<ErrorBoundary fallback={<>{fallback}</>}>
<Component {...props} />
</ErrorBoundary>
);
};
WrappedComponent.displayName = `withErrorBoundary(${Component.displayName ?? Component.name ?? 'Component'})`;
return WrappedComponent;
}
export { withErrorBoundary };