mirror of
https://github.com/morten-olsen/refocus.dev.git
synced 2026-02-08 00:46:25 +01:00
fixes
This commit is contained in:
@@ -65,7 +65,7 @@ const Board: React.FC<BoardProps> = ({ board, id }) => {
|
||||
))}
|
||||
</Masonry>
|
||||
</View>
|
||||
</View>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
35
packages/ui/src/interface/error/index.tsx
Normal file
35
packages/ui/src/interface/error/index.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react';
|
||||
|
||||
type State = {
|
||||
hasError: boolean;
|
||||
error?: unknown;
|
||||
};
|
||||
|
||||
type Props = {
|
||||
children: React.ReactNode;
|
||||
};
|
||||
|
||||
class ErrorBoundary extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = { hasError: false };
|
||||
}
|
||||
|
||||
static getDerivedStateFromError(error: unknown) {
|
||||
return { hasError: true, error };
|
||||
}
|
||||
|
||||
componentDidCatch(error: any, errorInfo: any) {
|
||||
console.error('componentDidCatch', error, errorInfo);
|
||||
}
|
||||
|
||||
render() {
|
||||
if (this.state.hasError) {
|
||||
return <h1>Something went wrong.</h1>;
|
||||
}
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
}
|
||||
|
||||
export { ErrorBoundary };
|
||||
@@ -4,3 +4,4 @@ export * from './notifications';
|
||||
export * from './widget';
|
||||
export * from './board';
|
||||
export * from './app';
|
||||
export * from './error';
|
||||
|
||||
@@ -19,6 +19,7 @@ import { DropdownMenu } from '../../base';
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
import { Typography } from '../../typography';
|
||||
import { NotificationView } from './notification';
|
||||
import { ErrorBoundary } from '../error';
|
||||
|
||||
type WidgetProps = {
|
||||
id: string;
|
||||
@@ -129,7 +130,9 @@ const Widget: React.FC<WidgetProps> = ({
|
||||
<Dialog.Overlay />
|
||||
<Dialog.Content maxWidth="90vw" height="90vh">
|
||||
<Dialog.CloseButton />
|
||||
<WidgetView />
|
||||
<ErrorBoundary>
|
||||
<WidgetView />
|
||||
</ErrorBoundary>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
</Dialog>
|
||||
@@ -169,7 +172,9 @@ const Widget: React.FC<WidgetProps> = ({
|
||||
>
|
||||
<Wrapper className={className} $fr>
|
||||
<WidgetWrapper $f={1}>
|
||||
<WidgetView />
|
||||
<ErrorBoundary>
|
||||
<WidgetView />
|
||||
</ErrorBoundary>
|
||||
</WidgetWrapper>
|
||||
</Wrapper>
|
||||
</motion.div>
|
||||
@@ -179,7 +184,9 @@ const Widget: React.FC<WidgetProps> = ({
|
||||
<Dialog.Content>
|
||||
<Dialog.Title>Edit Widget</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
<WidgetEditor onSave={onSave} />
|
||||
<ErrorBoundary>
|
||||
<WidgetEditor onSave={onSave} />
|
||||
</ErrorBoundary>
|
||||
</Dialog.Description>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
|
||||
Reference in New Issue
Block a user