| Total Complexity | 3 |
| Total Lines | 18 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | import React from 'react' |
||
| 4 | |||
| 5 | class ErrorBoundary extends React.Component { |
||
| 6 | constructor(props) { |
||
| 7 | 2 | super(props) |
|
| 8 | 2 | this.state = { hasError: false } |
|
| 9 | } |
||
| 10 | |||
| 11 | static getDerivedStateFromError(error) { |
||
| 12 | 1 | return { error, hasError: true } |
|
| 13 | } |
||
| 14 | |||
| 15 | render() { |
||
| 16 | 4 | if (this.state.hasError || this.props.reduxError) { |
|
| 17 | // You can render any custom fallback UI |
||
| 18 | 2 | return <Error error={this.props.reduxError || this.state.error} /> |
|
| 19 | } |
||
| 20 | |||
| 21 | 1 | return this.props.children |
|
| 22 | } |
||
| 30 |