1 | import React, { Component } from 'react';
|
2 |
|
3 | export default class ErrorBoundary extends React.Component {
|
4 | constructor(props) {
|
5 | super(props);
|
6 | this.state = { hasError: false };
|
7 | }
|
8 |
|
9 | componentDidCatch(error, info) {
|
10 | this.setState({ hasError: true });
|
11 | }
|
12 |
|
13 | unstable_handleError(error, info) {
|
14 | this.setState({ hasError: true });
|
15 | }
|
16 |
|
17 | render() {
|
18 | if (this.state.hasError) {
|
19 | return <h1>Slider error.</h1>;
|
20 | }
|
21 | return this.props.children;
|
22 | }
|
23 | } |
\ | No newline at end of file |