import 'whatwg-fetch';
import CascaderSelect from '..';
import React from 'react';
import ReactDOM from 'react-dom';
interface PageStates {
  data: Array<any>;
}
class Demo extends React.Component<{}, PageStates> {
  handleChange: (value: any, data: any, extra: any) => void;
  constructor(props) {
    super(props);

    this.handleChange = (value, data, extra) => {
      console.log(value, data, extra);
    };
    this.state = {
      data: [],
    };
  }

  componentDidMount() {
    fetch('https://os.alipayobjects.com/rmsportal/ODDwqcDFTLAguOvWEolX.json')
      .then(response => response.json())
      .then(data => {
        this.setState({ data });
      })
      .catch(e => console.log(e));
  }

  render() {
    return (
      <div>
        <CascaderSelect
          dataSource={this.state.data}
          onChange={this.handleChange}
        />
        <br/>
        <br/>
        <div style={{ backgroundColor: '#f3f3f3', padding: '10px' }}>
          <CascaderSelect
            theme='grey'
            dataSource={this.state.data}
            onChange={this.handleChange}
          />

        </div>

      </div>

    );
  }
}
ReactDOM.render(<Demo />, document.getElementById('cascader-select-demo-1'));
