Appointment Planner -

It said Define a callback function that, given a name, phone number, and email, adds a new contact object with that data to the array of contacts:

const [contacts, setContacts] = useState()
const addContacts = (contact) => { setContacts(prev => […prev, contact]) };

How can I add name, phone number and email as the objects of contact?

Instead of passing in contact as a parameter, you can pass in the parameters of name, phone and email and return them as the key-value pairs of a new contact object. This is how I got the addContact function to work:

const addContact = (name, phone, email) => {
setContacts(prevContacts => {
return [
…prevContacts,
{name, phone, email}
]
});
};