On my component I use a custom component for displaying numbers- I need onChange to get the input value, I have tried the below but I get a type error:
Type '(event: any) => void' is not assignable to type '() => void'.ts(2322)
export default function Test({param}) {
const onChange = key => event => {
const value = parseInt(event.target.value.replace(/[^0-9]/g, ''))
const x = {...param.x}
x.y[key] = value
setX(param => ({
...param,
payment: x
}))
}
return (
<>
<NumberListItem
label="test"
value={(param.payment)}
onChange={onChange('payment')}
inputProps={{decimalScale: 0, suffix: ' %'}}
/>
</>
)
}
NumberListItem component:
export default function NumberListItem({
value = '',
onChange = () => {},
...rest
}) {
return (
<ListItem>
<NumberField
value={value}
onChange={onChange}
{...rest}
/>
</ListItem>
)
}
NumberField component:
export default function NumberField(props: TextFieldProps & NumberFormatProps) {
return (
<TextField
{...props}
InputProps={{
inputComponent: NumberFormatCustom
}}
/>
)
}
onChange = () => {}toonChange = (e: any) => {}'e' is defined but never usederroronChange = () => {}onNumberListItemtoonChange = (e: any) => {}