Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev Autor Línea Nro. Línea
1197 stevensc 1
import React from 'react'
2
import { connect } from 'react-redux'
1202 stevensc 3
 
1565 stevensc 4
import { addNotification } from '@app/redux/notification/notification.actions'
1197 stevensc 5
 
6
class ErrorBoundary extends React.Component {
2204 stevensc 7
  static handleError(error, errorInfo) {
8
    console.log('ErrorBoundary caught an error: ', error, errorInfo)
9
    console.log(error.details)
10
    console.log(error.message)
11
    console.log(errorInfo)
12
    this.props.addNotification({ style: 'danger', msg: error.message })
1606 stevensc 13
  }
14
 
1197 stevensc 15
  componentDidCatch(error, errorInfo) {
2204 stevensc 16
    this.handleError(error, errorInfo)
1197 stevensc 17
  }
18
 
19
  render() {
20
    return this.props.children
21
  }
22
}
23
 
24
const mapDispatchToProps = {
25
  addNotification: (notification) => addNotification(notification)
26
}
27
 
28
export default connect(null, mapDispatchToProps)(ErrorBoundary)