Took this component from MUI docs
export interface CustomProps {
onChange: (event: { target: { name: string; value: string } }) => void;
name: string;
}
const NumberFormatCustom = React.forwardRef<NumberFormat, CustomProps>(
function NumberFormatCustom(props, ref) {
const { onChange, ...other } = props;
return (
<NumberFormat
{...other}
getInputRef={ref}
onValueChange={(values) => {
onChange({
target: {
name: props.name,
value: values.value,
},
});
}}
thousandSeparator
isNumericString
prefix="$"
/>
);
},
);
then it is used like this
<TextField
label="react-number-format"
value={values.numberformat}
onChange={handleChange}
name="numberformat"
id="formatted-numberformat-input"
InputProps={{
inputComponent: NumberFormatCustom as any, //Here
}}
variant="standard"
/>
Now the question is how do I pass props to NumberFormat? How can I even use it <NumberFormatCustom name='???' onChange={???}></NumberFormatCustom>
InputProps ={{inputComponent: <NumberFormatCustom name='???' />}}?