I am having a problem of how to have a key so that when I click the edit button, Input field must show on row depending on what row I clicked.
The output is when I click edit button, All input fields of the row are showing.
Here is my code:
constructor(props) {
super(props);
this.state = {
editable: false,
};
Here is the function that is executing when I click the click button:
edit = () => {
this.setState({
editable: true,
})
}
Here is my loop where I want to put the key
for (let i = 0; i < data.length; i++){
withKeys = {
...data[i],
key: i,
actionIndex: (
<>
{this.state.editable ? (
<span>
<EditableContext.Consumer>
{form => (
<a
onClick={() => this.save(form, data[i])}
style={{ marginRight: 8 }}
>
Save
</a>
)}
</EditableContext.Consumer>
<Popconfirm title="Sure to cancel?" onConfirm={this.cancel}>
<a>Cancel</a>
</Popconfirm>
</span>
):
<Button
onClick={this.edit}
ghost
type="primary"
>
Edit
</Button> }
How can I add key so that when I click the edit button, input field must show depending on the row where I select the edit button. By the way I am using ant design