Proyectos de Subversion LeadersLinked - SPA

Rev

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

import React from 'react'
import { connect } from 'react-redux'

import { addNotification } from '@app/redux/notification/notification.actions'

class ErrorBoundary extends React.Component {
  static handleError(error, errorInfo) {
    console.log('ErrorBoundary caught an error: ', error, errorInfo)
    console.log(error.details)
    console.log(error.message)
    console.log(errorInfo)
    this.props.addNotification({ style: 'danger', msg: error.message })
  }

  componentDidCatch(error, errorInfo) {
    this.handleError(error, errorInfo)
  }

  render() {
    return this.props.children
  }
}

const mapDispatchToProps = {
  addNotification: (notification) => addNotification(notification)
}

export default connect(null, mapDispatchToProps)(ErrorBoundary)