'Change the input text file in react

New to React and using a simple table. I'm just testing to change an input text value when I select a button on the same row.

enter image description here

The code below is where I'm stuck. I'm trying to figure out how to change the state value "users" for this row when I click on the button. I'm trying to set the first_name to "Testing".

const [users, setUsers] = React.useState(null);

let usersList =
    businessUsersState.data.length > 0 &&
    businessUsersState.data.map((item: any, key: number) => {
                return (
        <tr key={key} data-account={item.account_id}>
            <td>
                <Form.Control name="first-name" type="input" placeholder="First Name" defaultValue={item.first_name} />
            </td>
            <td>
                <Button variant="primary" type="button" onClick={() => {
            debugger;
            const row = businessUsersState.data.map((item: any) => ({...item}));
            row[key].first_name = 'Testing';
            
            const row1 = usersList[key];

            
            //setUserRow(row);
            //setUsers(row);
        }}>
                </Button>
            </td>
        </tr>
    );
    });

setUsers(usersList);

I was reading the following link but I cant seem to get it to work. Any help is appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source