Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3456 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 3456 Rev 3719
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
 
3
 
4
import { addNotification } from '@app/redux/notification/notification.actions';
4
import { addNotification } from '@store/notification/notification.actions';
5
import { asyncLogout } from '@store/auth/auth.actions';
-
 
6
 
5
 
7
class ErrorBoundary extends React.Component {
6
class ErrorBoundary extends React.Component {
8
  constructor(props) {
7
  constructor(props) {
9
    super(props);
8
    super(props);
10
    this.state = { hasError: false };
9
    this.state = { hasError: false };
11
  }
10
  }
12
 
11
 
13
  static getDerivedStateFromError() {
12
  static getDerivedStateFromError() {
14
    return { hasError: true };
13
    return { hasError: true };
15
  }
14
  }
16
 
15
 
17
  componentDidCatch(error, errorInfo) {
16
  componentDidCatch(error, errorInfo) {
18
    console.error('ErrorBoundary caught an error: ', error, errorInfo);
17
    console.error('ErrorBoundary caught an error: ', error, errorInfo);
19
    //this.props.logout();
-
 
20
    this.props.addNotification({ style: 'danger', msg: 'Ha ocurrido un error inesperado' });
18
    this.props.addNotification({ style: 'danger', msg: 'Ha ocurrido un error inesperado' });
21
  }
19
  }
22
 
20
 
23
  render() {
21
  render() {
24
    return this.props.children;
22
    return this.props.children;
25
  }
23
  }
26
}
24
}
27
 
25
 
28
const mapDispatchToProps = {
26
const mapDispatchToProps = {
29
  addNotification: (notification) => addNotification(notification),
27
  addNotification: (notification) => addNotification(notification)
30
  logout: () => asyncLogout()
-
 
31
};
28
};
32
 
29
 
33
export default connect(null, mapDispatchToProps)(ErrorBoundary);
30
export default connect(null, mapDispatchToProps)(ErrorBoundary);