Skip to content

Commit 53c267b

Browse files
committed
fallback ui for error boundary
1 parent 81d072c commit 53c267b

File tree

3 files changed

+10
-25
lines changed

3 files changed

+10
-25
lines changed

client/packages/lowcoder/src/app.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import { SystemWarning } from "./components/SystemWarning";
5353
import { getBrandingConfig } from "./redux/selectors/configSelectors";
5454
import { buildMaterialPreviewURL } from "./util/materialUtils";
5555
import GlobalInstances from 'components/GlobalInstances';
56-
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
5756

5857
const LazyUserAuthComp = React.lazy(() => import("pages/userAuth"));
5958
const LazyInviteLanding = React.lazy(() => import("pages/common/inviteLanding"));
@@ -90,10 +89,6 @@ type AppIndexProps = {
9089
};
9190

9291
class AppIndex extends React.Component<AppIndexProps, any> {
93-
constructor(props: any) {
94-
super(props);
95-
this.state = {error: null};
96-
}
9792
componentDidMount() {
9893
this.props.getCurrentUser();
9994
}
@@ -106,16 +101,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
106101
this.props.fetchConfig(this.props.currentOrgId);
107102
}
108103
}
109-
updateError = () => {
110-
this.state.error('known');
111-
};
112-
fallbackRender = ({error, resetErrorBoundary}: FallbackProps) => {
113-
return <div role="alert">
114-
<h3>Error Boundary</h3>
115-
<p>Something went wrong.</p>
116-
<button onClick={resetErrorBoundary}>Reset</button>
117-
</div>;
118-
};
119104
render() {
120105
const isTemplate = hasQueryParam('template');
121106
const pathname = history.location.pathname;
@@ -281,12 +266,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
281266
]}
282267
</Helmet>
283268
<SystemWarning />
284-
<ErrorBoundary
285-
fallbackRender={this.fallbackRender}
286-
onReset={(details) => {
287-
this.state.error(null);
288-
}}
289-
>
290269
<Router history={history}>
291270
<Switch>
292271
{/*
@@ -387,7 +366,6 @@ class AppIndex extends React.Component<AppIndexProps, any> {
387366
)}
388367
</Switch>
389368
</Router>
390-
</ErrorBoundary>
391369
</Wrapper>
392370
);
393371
}

client/packages/lowcoder/src/layout/gridItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ export function GridItem(props: GridItemProps) {
417417
const render = () => {
418418
let child = React.Children.only(children);
419419
// Create the child element. We clone the existing element but modify its className and style.
420-
let newChild: React.ReactElement = React.cloneElement(withErrorBoundary(child), {
420+
let newChild: React.ReactElement = React.cloneElement(child, {
421421
ref: elementRef,
422422
className: clsx(
423423
"react-grid-item",

client/packages/lowcoder/src/pages/editor/AppEditor.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { DatasourceApi } from "api/datasourceApi";
2828
import { useRootCompInstance } from "./useRootCompInstance";
2929
import EditorSkeletonView from "./editorSkeletonView";
3030
import {ErrorBoundary, FallbackProps} from 'react-error-boundary';
31+
import { ALL_APPLICATIONS_URL } from "@lowcoder-ee/constants/routesURL";
32+
import history from "util/history";
3133

3234
const AppSnapshot = lazy(() => {
3335
return import("pages/editor/appSnapshot")
@@ -133,9 +135,14 @@ export default function AppEditor() {
133135
})
134136
);
135137
}, [viewMode, applicationId, dispatch]);
136-
138+
const fallbackUI = (
139+
<div style={{display:'flex', height:'100%', width:'100%', alignItems:'center',justifyContent:'center', gap:'8px',marginTop:'10px'}}>
140+
<p style={{margin:0}}>Something went wrong while displaying this webpage</p>
141+
<button onClick={() => history.push(ALL_APPLICATIONS_URL)} style={{background: '#4965f2',border: '1px solid #4965f2', color: '#ffffff',borderRadius:'6px'}}>Go to Apps</button>
142+
</div>
143+
);
137144
return (
138-
<ErrorBoundary fallback={<p>⚠️Something went wrong</p>}>
145+
<ErrorBoundary fallback={fallbackUI}>
139146
{showAppSnapshot ? (
140147
<Suspense fallback={<EditorSkeletonView />}>
141148
<AppSnapshot

0 commit comments

Comments
 (0)