I have an array of button that is rendered using .map to print out the rows in data table. Each row have button that trigger the Edit panel popup. The problem that I currently have is when one button is clicked, the Edit panel on all rows.
The code:
const [showEdit, setShowEdit] = useState([]);
<tbody>
{appSettingsList.map((appSettings, i) => (
<tr key={i}>
<td>{appSettings.Name}</td>
<td>{appSettings.BackgroundColor}</td>
<td>{appSettings.FontSize}</td>
<td>{appSettings.FontFamily}</td>
<td>{appSettings.Theme}</td>
<td>{appSettings.NavigationBar}</td>
<td className="action-column">
<button
key={i}
className="button-green"
onClick={() => setShowEdit(!showEdit)}
>
Edit
</button>
</td>
<td>{showEdit ? <EditApplicationSettings /> : null}</td>
</tr>
))}
</tbody>
How can I make that each button have different state?