Lets say I have two interfaces which share two fields.
interface user {
id: string;
email: string;
name: string
}
interface contactRequest {
id: string;
email: string;
time: Date
}
Is there a way to create a function which will set the state for both of these interfaces?
const setId_Email = (id: string, email: string, setState: Dispatch<SetStateAction<????>>) => {
setState(prevState => ({
...prevState, id, email
}));
}
What could I put inside the SetStateAction brackets to accept any interface that has an id and email field?