I am using RadioGroup component from the React material-UI library in a TypeScript project, and I have question about the onChange callback signature definition. Looking at the documentation (https://mui.com/material-ui/api/radio-group/) the signature for the callback is function(event: React.ChangeEvent<HTMLInputElement>, value: string) => void.
However, with the following code I get the error Type ‘(event: ChangeEvent<HTMLInputElement>, nextValue: string) => void’ is not assignable to type ‘(nextValue: string) => void’
Code snippet 1:
const handleEvent = (event: React.ChangeEvent<HTMLInputEvent>, value: String) => {
...
}
<RadioGroup onChange={handleEvent} value={String(1234)}>
...
</RadioGroup>
The problem does not show when the following code snippet
Code snippet 2:
const handleEvent = (value: String) => {
...
}
<RadioGroup onChange={handleEvent} value={String(1234)}>
...
</RadioGroup>
I would expect the first snippet to work because the signature of the callback matches with the signature in the documentation, however that is not the case when executing the code. Can someone help me understand what is going on?