Currently, I am referencing an example code snippet from react-hook-form. However, upon implementation, I encounter the following error:
(parameter) label: any
Binding element 'label' implicitly has an 'any' type.ts(7031)
The example code is as follows:
const options = [
{ value: 'chocolate', label: 'Chocolate' },
{ value: 'strawberry', label: 'Strawberry' },
{ value: 'vanilla', label: 'Vanilla' },
];
const MyInput = ({ label, name, onChange, onBlur, ref }) => {
return (
<>
<label htmlFor={name}>{label}</label>
<input
name={name}
placeholder="Jane"
onChange={onChange}
onBlur={onBlur}
ref={ref}
/>
</>
);
};
This leads to the same error message:
(parameter) label: any
Binding element 'label' implicitly has an 'any' type.ts(7031)
Even after assigning types, the error persists:
interface InputProps {
label: string,
name: string,
onChange: any,
onBlur: any,
ref: any
}
const MyInput = ({ label, name, onChange, onBlur, ref }):InputProps => {
return (
<>
<label htmlFor={name}>{label}</label>
<input
name={name}
placeholder="Jane"
onChange={onChange}
onBlur={onBlur}
ref={ref}
/>
</>
);
};
I'm currently working with Next.js, not sure if that affects anything?