I am working with an array containing last names of Persons and need to populate new entries. However, I only have the last names and not the full Person objects. How can I address this issue?
type Person = {
name: string,
lastName: string,
age: number
}
function MyComponent() {
const [persons, setPersons] = useState<Person[]>([])
function addNewPersons(lastName: string[]): void {
setPersons((prevState: Person[]) => [
...prevState,
// spread lastName[] onto Person[]
]);
}
return <></>;
}