Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3456 | | Comparar con el anterior | Ultima modificación | Ver Log |

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