Answer the question
In order to leave comments, you need to log in
What type for event it is necessary to register?
Good evening, please tell me how to correctly register the type in this case? I use select from material ui. currentTarget.innerText I use to find out what text is in the MenuItem
const handleChange = (event: any) => {
if (
event.currentTarget.innerText === 'BALANCE'
) {
setSendForm({...sendForm, balance: event.target.value});
setCBal(true);
} else {
setSendForm({...sendForm, balance: event.target.value});
setCBal(false);
}
};
<Select
labelId="balance-select-label"
id="balance-select"
required
value={sendForm.balance}
onChange={handleChange}
>
{balances.map((i: UserB, index: number) => (
<MenuItem key={index} value={i.id}>{i.account}</MenuItem>
))}
</Select>
Answer the question
In order to leave comments, you need to log in
event.currentTarget.options[event.currentTarget.selectedIndex].text
type TypescriptInferTheEventTypeForMePlease
= HTMLSelectElement['addEventListener'] extends ((
eventName: 'change',
cb: (event: infer E) => any
) => any)
? E
: never;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question