import React, {Component} from 'react'; import {Row, Col, Input, Icon, Button} from 'antd'; import './index.css'; import Change from './change'; const Search = Input.Search; class Schema extends Component { constructor(props) { super(props); this.state = { currentSchema: 'magazine', currentTable: 'user', switch: true } } changeSchema = (schema) => { return () => { this.setState({ currentSchema: schema }) } }; changeTable = (table) => { return () => { this.setState({ currentTable: table }) } }; findColumns = () => { let schema = this.props.schemas.find(schema => schema.name === this.state.currentSchema); if(schema === undefined) return []; // if user insert a new schema, after merge to schemas with a {name: 'xx', tables: []} // you can find the following table is undefined. // so give a state here if you want add a tip! else { let table = schema.tables.find(table => table.name === this.state.currentTable); if(table === undefined) return []; else return table.cols; } }; render() { return (