I am making something in the following picture:
I wrote the following code:
{ persons.map((person) => <li key = {person.id}>
<Person name={person.name} number={person.number}/>
<Button text={'Delete'} handler={deleteHandler} />
</li>) }
The problem I am facing is, How to make the button (deleteHandler) work and delete the contact associated with it?
What I think should be done -> find out the key associated (key in < li>) with the button and delete it from the array. But then How do I find the key of < li> associated with the button?
Note - I am using React hooks for state changes (NOT the classes), so, please suggest the answer accordingly.
Thanks
