score:0

inside person.js you can delete by using a callback to get the id

<button onclick={()=>deletecontact(person.id)}>delete {person.id} </button>

import react from 'react'
import axios from 'axios'
const baseurl = 'http://localhost:3001/persons'


const deletecontact = (id)=>{
  const request = axios.delete('{$baseurl}/${id}')
  request.then(response =>response.data)
  }

const person = ({ person, deletecontact }) => {
   console.log("person.js props "+person.id)
   
    return (
      <li> 
        {person.name} {person.number}  
        <button onclick={()=>deletecontact(person.id)}>delete {person.id} </button> 
      </li>
    )
  }

  export default person

Related Query

More Query from same tag