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>
|
</Masonry>
|
||||||
</View>
|
</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 './widget';
|
||||||
export * from './board';
|
export * from './board';
|
||||||
export * from './app';
|
export * from './app';
|
||||||
|
export * from './error';
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import { DropdownMenu } from '../../base';
|
|||||||
import { useCallback, useMemo, useState } from 'react';
|
import { useCallback, useMemo, useState } from 'react';
|
||||||
import { Typography } from '../../typography';
|
import { Typography } from '../../typography';
|
||||||
import { NotificationView } from './notification';
|
import { NotificationView } from './notification';
|
||||||
|
import { ErrorBoundary } from '../error';
|
||||||
|
|
||||||
type WidgetProps = {
|
type WidgetProps = {
|
||||||
id: string;
|
id: string;
|
||||||
@@ -129,7 +130,9 @@ const Widget: React.FC<WidgetProps> = ({
|
|||||||
<Dialog.Overlay />
|
<Dialog.Overlay />
|
||||||
<Dialog.Content maxWidth="90vw" height="90vh">
|
<Dialog.Content maxWidth="90vw" height="90vh">
|
||||||
<Dialog.CloseButton />
|
<Dialog.CloseButton />
|
||||||
|
<ErrorBoundary>
|
||||||
<WidgetView />
|
<WidgetView />
|
||||||
|
</ErrorBoundary>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
</Dialog.Portal>
|
</Dialog.Portal>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
@@ -169,7 +172,9 @@ const Widget: React.FC<WidgetProps> = ({
|
|||||||
>
|
>
|
||||||
<Wrapper className={className} $fr>
|
<Wrapper className={className} $fr>
|
||||||
<WidgetWrapper $f={1}>
|
<WidgetWrapper $f={1}>
|
||||||
|
<ErrorBoundary>
|
||||||
<WidgetView />
|
<WidgetView />
|
||||||
|
</ErrorBoundary>
|
||||||
</WidgetWrapper>
|
</WidgetWrapper>
|
||||||
</Wrapper>
|
</Wrapper>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -179,7 +184,9 @@ const Widget: React.FC<WidgetProps> = ({
|
|||||||
<Dialog.Content>
|
<Dialog.Content>
|
||||||
<Dialog.Title>Edit Widget</Dialog.Title>
|
<Dialog.Title>Edit Widget</Dialog.Title>
|
||||||
<Dialog.Description>
|
<Dialog.Description>
|
||||||
|
<ErrorBoundary>
|
||||||
<WidgetEditor onSave={onSave} />
|
<WidgetEditor onSave={onSave} />
|
||||||
|
</ErrorBoundary>
|
||||||
</Dialog.Description>
|
</Dialog.Description>
|
||||||
</Dialog.Content>
|
</Dialog.Content>
|
||||||
</Dialog.Portal>
|
</Dialog.Portal>
|
||||||
|
|||||||
Reference in New Issue
Block a user