Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3451 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

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