Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //error-boundry.js
- import React, { Component } from 'react';
- import ErrorIndicator from '../error-indicator';
- export default class ErrorBoundry extends Component {
- state = {
- hasError: false
- };
- componentDidCatch() {
- this.setState({
- hasError: true
- });
- }
- render() {
- if (this.state.hasError) {
- return <ErrorIndicator />
- }
- return this.props.children;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment