add errorboundary
This commit is contained in:
@@ -38,6 +38,7 @@ import { checkValidCountry } from "../lunaSend/common";
|
|||||||
import { lunaTest } from "../lunaSend/lunaTest";
|
import { lunaTest } from "../lunaSend/lunaTest";
|
||||||
import * as Config from "../utils/Config";
|
import * as Config from "../utils/Config";
|
||||||
import { $L, clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
import { $L, clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
||||||
|
import ErrorBoundary from "../views/ErrorBoundary";
|
||||||
import MainView from "../views/MainView/MainView";
|
import MainView from "../views/MainView/MainView";
|
||||||
import css from "./App.module.less";
|
import css from "./App.module.less";
|
||||||
import { getMenuByLinkTpCd, handleDeepLink } from "./deepLinkHandler";
|
import { getMenuByLinkTpCd, handleDeepLink } from "./deepLinkHandler";
|
||||||
@@ -326,14 +327,16 @@ function AppBase(props) {
|
|||||||
}, [dispatch]);
|
}, [dispatch]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<MainView
|
<ErrorBoundary>
|
||||||
className={
|
<MainView
|
||||||
typeof window === "object" &&
|
className={
|
||||||
!window.PalmSystem &&
|
typeof window === "object" &&
|
||||||
!cursorVisible &&
|
!window.PalmSystem &&
|
||||||
css.preventMouse
|
!cursorVisible &&
|
||||||
}
|
css.preventMouse
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
38
com.twin.app.shoptime/src/views/ErrorBoundary.js
Normal file
38
com.twin.app.shoptime/src/views/ErrorBoundary.js
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import React, { Component } from "react";
|
||||||
|
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
|
import { clearLaunchParams } from "../utils/helperMethods";
|
||||||
|
|
||||||
|
class ErrorBoundary extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = { hasError: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
static getDerivedStateFromError(error) {
|
||||||
|
return { hasError: true };
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidCatch(error, errorInfo) {
|
||||||
|
console.error("Uncaught error:", error, errorInfo);
|
||||||
|
}
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
if (this.state.hasError) {
|
||||||
|
clearLaunchParams();
|
||||||
|
if (typeof window === "object") {
|
||||||
|
window.location.reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
if (this.state.hasError) {
|
||||||
|
return <div>Something went wrong.</div>;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.props.children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect()(ErrorBoundary);
|
||||||
Reference in New Issue
Block a user