ErrorBoundary....reload app
This commit is contained in:
@@ -41,6 +41,7 @@ import { $L, clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
|
||||
import MainView from "../views/MainView/MainView";
|
||||
import css from "./App.module.less";
|
||||
import { getMenuByLinkTpCd, handleDeepLink } from "./deepLinkHandler";
|
||||
import ErrorBoundary from "../views/ErrorBoundary";
|
||||
|
||||
let foreGroundChangeTimer = null;
|
||||
|
||||
@@ -302,14 +303,9 @@ function AppBase(props) {
|
||||
}, [dispatch]);
|
||||
|
||||
return (
|
||||
<MainView
|
||||
className={
|
||||
typeof window === "object" &&
|
||||
!window.PalmSystem &&
|
||||
!cursorVisible &&
|
||||
css.preventMouse
|
||||
}
|
||||
/>
|
||||
<ErrorBoundary>
|
||||
<MainView className={typeof window === "object" && !window.PalmSystem && !cursorVisible && css.preventMouse} />
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
36
com.twin.app.shoptime/src/views/ErrorBoundary.js
Normal file
36
com.twin.app.shoptime/src/views/ErrorBoundary.js
Normal file
@@ -0,0 +1,36 @@
|
||||
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