Guest User

Untitled

a guest
Apr 25th, 2020
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //error-boundry.js
  2. import React, { Component } from 'react';
  3.  
  4. import ErrorIndicator from '../error-indicator';
  5.  
  6. export default class ErrorBoundry extends Component {
  7.  
  8.   state = {
  9.     hasError: false
  10.   };
  11.  
  12.   componentDidCatch() {
  13.     this.setState({
  14.       hasError: true
  15.     });
  16.   }
  17.  
  18.   render() {
  19.  
  20.     if (this.state.hasError) {
  21.       return <ErrorIndicator />
  22.     }
  23.  
  24.     return this.props.children;
  25.   }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment