Skip to content

Commit

Permalink
[js] odstraneni zbytecneho konstruktoru
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlukas committed Mar 17, 2020
1 parent ce2dc2c commit 29c4546
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions frontend/src/pages/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import { Alert, Col, Container, Row } from "reactstrap"
import Token from "../auth/Token"
import CustomButton from "../components/buttons/CustomButton"
import Heading from "../components/Heading"
import { noop } from "../global/utils"
import { TokenDecodedType } from "../types/models"
import { CustomRouteComponentProps } from "../types/types"
import { CustomRouteComponentProps, fEmptyVoid } from "../types/types"

type Props = CustomRouteComponentProps

Expand All @@ -31,14 +32,19 @@ class ErrorBoundary extends React.Component<Props, State> {
errorInfo: undefined
}

constructor(props: Props) {
super(props)
unlisten: fEmptyVoid = noop

componentDidMount(): void {
// aby fungoval react-router pri nejake chybe
this.props.history.listen(() => {
this.unlisten = this.props.history.listen(() => {
if (this.state.hasError) this.setState({ hasError: false })
})
}

componentWillUnmount(): void {
this.unlisten()
}

static getDerivedStateFromError(): Partial<State> {
// v pripade, ze doslo k chybe pri otvirani formulare, odstran tento priznak z body
// jinak bude pro body nastaveno overflow: hidden a nepujde scrollovat
Expand Down

0 comments on commit 29c4546

Please sign in to comment.