// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import React from 'react';
/**
 * @internal
 * ErrorBoundary component to handle errors in React components.
 */
export class _ErrorBoundary extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            hasError: false
        };
    }
    static getDerivedStateFromError() {
        // Update state so the next render will show the fallback UI.
        return {
            hasError: true
        };
    }
    componentDidCatch(error) {
        console.error(error);
    }
    render() {
        if (this.state.hasError) {
            // handle error
            return this.props.fallback;
        }
        // otherwise render children
        return this.props.children;
    }
}
//# sourceMappingURL=ErrorBoundary.js.map