Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 1219 Rev 1562
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 } from '@mui/material'
-
 
Línea 4... Línea 3...
4
 
3
 
5
import { addNotification } from '../../redux/notification/notification.actions'
-
 
Línea 6... Línea 4...
6
import { ButtonPrimary } from '@buttons'
4
import { addNotification } from '../../redux/notification/notification.actions'
7
 
-
 
8
class ErrorBoundary extends React.Component {
-
 
9
  constructor(props) {
-
 
10
    super(props)
-
 
11
    this.state = { hasError: false }
-
 
12
  }
-
 
13
 
-
 
14
  static getDerivedStateFromError() {
-
 
15
    return { hasError: true }
-
 
16
  }
5
 
17
 
6
class ErrorBoundary extends React.Component {
18
  componentDidCatch(error, errorInfo) {
7
  componentDidCatch(error, errorInfo) {
19
    console.error('ErrorBoundary caught an error: ', error, errorInfo)
8
    console.error('ErrorBoundary caught an error: ', error, errorInfo)
Línea 20... Línea 9...
20
    this.props.addNotification({ style: 'danger', msg: error.message })
9
    this.props.addNotification({ style: 'danger', msg: error.message })
21
  }
-
 
22
 
-
 
23
  render() {
-
 
24
    if (this.state.hasError) {
-
 
25
      return (
-
 
26
        <Container>
-
 
27
          <h1>Something went wrong, please reload the page</h1>
-
 
28
 
-
 
29
          <ButtonPrimary
-
 
30
            className='mt-3'
-
 
31
            onClick={() => window.location.reload(true)}
-
 
32
            label='Reload'
-
 
33
          />
-
 
34
        </Container>
-
 
35
      )
10
  }
36
    }
11
 
37
 
12
  render() {
Línea 38... Línea 13...
38
    return this.props.children
13
    return this.props.children