import Button from '../../button';
import ConfigProvider from '..';
import React from 'react';
import ReactDOM from 'react-dom';
const { config } = ConfigProvider;
class Demo extends React.Component {
    render() {
        if (this.props.throwError) {
            throw Error('There is something going wrong!');
        }
        else {
            return React.createElement("span", null, "normal");
        }
    }
}
const NewDemo = config(Demo);
// const fallbackUI = props => {
//   const { error, errorInfo } = props;
//   return <span style={{ color: 'red' }}>{error.toString()}</span>;
// };
class App extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            throwError: false,
        };
        this.onClick = () => {
            this.setState({
                throwError: true,
            });
        };
    }
    render() {
        return (React.createElement("div", null,
            "Click to throw an error",
            ' ',
            React.createElement(Button, { type: "primary", onClick: this.onClick }, "trigger error"),
            React.createElement("br", null),
            React.createElement("br", null),
            "Default fallback UI:",
            React.createElement("hr", null),
            React.createElement(ConfigProvider, { errorBoundary: true },
                React.createElement(NewDemo, { throwError: this.state.throwError })),
            React.createElement("br", null),
            React.createElement("br", null),
            "Customize fallback UI of configed Component(Basic Components / Biz Components):",
            React.createElement("hr", null),
            React.createElement(ConfigProvider, { errorBoundary: {
                    fallbackUI: (props) => {
                        const { error } = props;
                        return (React.createElement("span", { style: { color: 'red' } },
                            "Error: ",
                            error.toString()));
                    },
                    afterCatch: () => {
                        console.log('catching');
                    },
                } },
                React.createElement(NewDemo, { throwError: this.state.throwError }))));
    }
}
ReactDOM.render(React.createElement(App, null), document.getElementById('config-provider-demo-6'));
