How to create a new line in the Table of ant design

clipboard.png

clipboard.png
this is the effect

Mar.01,2021

the following list should be a list. When you create a new one, add an empty data to the list, and the list will automatically add a row of data.
as a rule of thumb, the addition must ensure the uniqueness of key .


clipboard.png
the following data is the data obtained by antdesign's table using columns


Click the add button to add an entry to the dataSource array, and update it

handleAdd = () => {
    const { count, dataSource } = this.state;
    const newData = {
      key: count,
      name: `Allan ${count}`,
      age: 22,
      address: `China, Hangzhou. ${count}`,
    };
    this.setState({
      dataSource: [...dataSource, newData],
      count: count + 1,
    });
}

if ps: is deleted, see the following

onDelete = (key) => {
    const dataSource = [...this.state.dataSource];
    this.setState({ dataSource: dataSource.filter(item => item.key !== key)    });
}
Menu