I am passing an onChange event as a props to a component But I am getting datatype error.
Parent Component -
const onChangeStatus=(selectType:string , e:React.ChangeEvent<HTMLSelectElement>) => {
const { options } = e.target;
console.log(options)
}
<GlobalSearchAssignmentFilter
onChangeAssignmentStatus={onChangeStatus}
/>
Child Component - I have defined an interface like
interface A {
onChangeAssignmentStatus: (
selectType: string,
event:React.ChangeEvent<HTMLInputElement>
) => void;
}
component code - <Select multiple native onChange={(event: React.ChangeEvent):void => onChangeAssignmentStatus(ASSIGNMENT_STATUS_PROPERTY , event) } inputProps={{ id: 'select-multiple-native', }} > {assignmentFilterData.assignmentDispositions.map((item: any) => ( {item.key} ))}
I am importing Select from Material UI multi select. I am getting error when I am passing onChangeAssignmentStatus event to child component. The error is -
Type '(selectType: string, e: React.ChangeEvent<HTMLSelectElement>) => void' is not assignable to type '(selectType: string, event: ChangeEvent<HTMLInputElement>) => void'.
Types of parameters 'e' and 'event' are incompatible.
Type 'ChangeEvent<HTMLInputElement>' is not assignable to type 'ChangeEvent<HTMLSelectElement>'.
Type 'HTMLInputElement' is missing the following properties from type 'HTMLSelectElement': length, options, selectedIndex, selectedOptions, and 3 more.
How can I resolve this error ?