Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 1565 | Rev 2195 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1565 Rev 1606
Línea 1... Línea 1...
1
import React from 'react'
1
import React from 'react'
2
import { connect } from 'react-redux'
2
import { connect } from 'react-redux'
-
 
3
import { Container, Typography } from '@mui/material'
Línea 3... Línea 4...
3
 
4
 
Línea -... Línea 5...
-
 
5
import { addNotification } from '@app/redux/notification/notification.actions'
-
 
6
 
4
import { addNotification } from '@app/redux/notification/notification.actions'
7
import Button from '@app/components/UI/buttons/Buttons'
-
 
8
 
-
 
9
class ErrorBoundary extends React.Component {
-
 
10
  constructor(props) {
-
 
11
    super(props)
-
 
12
    this.state = { hasError: false }
-
 
13
  }
-
 
14
 
-
 
15
  static getDerivedStateFromError() {
-
 
16
    return { hasError: true }
5
 
17
  }
6
class ErrorBoundary extends React.Component {
18
 
7
  componentDidCatch(error, errorInfo) {
19
  componentDidCatch(error, errorInfo) {
8
    console.error('ErrorBoundary caught an error: ', error, errorInfo)
20
    console.error('ErrorBoundary caught an error: ', error, errorInfo)
Línea 9... Línea 21...
9
    this.props.addNotification({ style: 'danger', msg: error.message })
21
    this.props.addNotification({ style: 'danger', msg: error.message })
-
 
22
  }
-
 
23
 
-
 
24
  render() {
-
 
25
    if (this.state.hasError) {
-
 
26
      return (
-
 
27
        <Container>
-
 
28
          <Typography variant='h1'>
-
 
29
            Something went wrong, please reload the page
-
 
30
          </Typography>
-
 
31
 
-
 
32
          <Button
-
 
33
            variant='primary'
-
 
34
            onClick={() => window.location.reload(true)}
-
 
35
          >
-
 
36
            Reload
-
 
37
          </Button>
-
 
38
        </Container>
10
  }
39
      )
11
 
40
    }
12
  render() {
41
 
Línea 13... Línea 42...
13
    return this.props.children
42
    return this.props.children