fix, not tested EditableTable

This commit is contained in:
Фролов 2021-08-11 11:44:20 +05:00
parent 056642f705
commit 139f73e968

View File

@ -1,6 +1,6 @@
import { Form, Input, Table, Button, Popconfirm } from "antd"
import { EditOutlined, SaveOutlined, PlusOutlined, CloseCircleOutlined, DeleteOutlined } from '@ant-design/icons'
import { useState } from "react";
import { useState, useEffect } from "react";
const newRowKeyValue = 'newRow'
@ -48,6 +48,10 @@ export const EditableTable = ({
const [data, setData] = useState(dataSource?? [])
const [editingKey, setEditingKey] = useState('')
useEffect(()=>{
setData(dataSource??[])
},[dataSource])
const isEditing = (record) => record.key === editingKey
const edit = (record) => {
@ -56,7 +60,7 @@ export const EditableTable = ({
}
const cancel = () => {
if(editingKey == newRowKeyValue)
if(editingKey === newRowKeyValue)
{
const newData = [...data]
const index = newData.findIndex((item) => newRowKeyValue === item.key)