Hi. When I click submit, I don’t get the result I want. Email doesn’t appear at all, and name and phone number appear letter by letter instead of the whole name.
Your addContact function expects two arguments:
const addContact = (prev, newContact) =>
{
setContacts([...prev, newContact]);
}
Apparently, the first being an array of objects, and the second being an object.
That is not what you provide as arguments in ContactsPage.js:
props.addContact(name,phone,email);
2 Likes
I tried
props.addContact([name,phone,email]);
but, I got: Cannot convert undefined or null to object.
Yes, now you’re passing just one argument rather than 3. But it should be 2.
Also: What type are name, phone and email? What what type should be set to the contact state?
Check what you need in Tile.js.
2 Likes
Thank you very much. It’s working somehow. I don’t know how to add the prev input.
I don’t understand: If it is working now, what do you need help with?
Thank you very much.
When I wrote props.addContact(props.contacts, [name,phone,email]); it worked.