Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 3407 Rev 3451
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';
Línea 3... Línea 3...
3
 
3
 
-
 
4
import { addNotification } from '@app/redux/notification/notification.actions';
Línea 4... Línea 5...
4
import { addNotification } from '@app/redux/notification/notification.actions'
5
import { asyncLogout } from '@store/auth/auth.actions';
5
 
6
 
6
class ErrorBoundary extends React.Component {
7
class ErrorBoundary extends React.Component {
7
  constructor(props) {
8
  constructor(props) {
8
    super(props)
9
    super(props);
Línea 9... Línea 10...
9
    this.state = { hasError: false }
10
    this.state = { hasError: false };
10
  }
11
  }
11
 
12
 
Línea 12... Línea 13...
12
  static getDerivedStateFromError() {
13
  static getDerivedStateFromError() {
13
    return { hasError: true }
14
    return { hasError: true };
14
  }
15
  }
15
 
-
 
16
  componentDidCatch(error, errorInfo) {
16
 
17
    console.error('ErrorBoundary caught an error: ', error, errorInfo)
-
 
18
    this.props.addNotification({
-
 
19
      style: 'danger',
-
 
20
      msg: 'Ha ocurrido un error en el inicio de sesión'
-
 
21
    })
-
 
22
    if (error.message.includes('sesión')) {
17
  componentDidCatch(error, errorInfo) {
Línea 23... Línea 18...
23
      window.localStorage.removeItem('jwt')
18
    console.error('ErrorBoundary caught an error: ', error, errorInfo);
24
      window.location.reload()
19
    this.props.logout();
25
    }
20
    this.props.addNotification({ style: 'danger', msg: 'Ha ocurrido un error inesperado' });
26
  }
21
  }
Línea 27... Línea 22...
27
 
22
 
28
  render() {
23
  render() {
-
 
24
    return this.props.children;
29
    return this.props.children
25
  }
Línea 30... Línea 26...
30
  }
26
}