Sometimes, we want to fix the "error TS2339: Property ‘for’ does not exist on type ‘HTMLProps’" error with TypeScript.
In this article, we’ll look at how to fix the "error TS2339: Property ‘for’ does not exist on type ‘HTMLProps’" error with TypeScript.
How to fix the "error TS2339: Property ‘for’ does not exist on type ‘HTMLProps’" error with TypeScript?
The "error TS2339: Property ‘for’ does not exist on type ‘HTMLProps’" error with TypeScript, we should replace the for
prop with the htmlFor
prop.
For instance, we write
const Input = (props) => {
//...
return (
<label htmlFor={props.inputId} className="input-label">
{props.label}
</label>
//...
);
};
to set the label
‘s for
attribute by setting the htmlFor
prop to a value.
Conclusion
The "error TS2339: Property ‘for’ does not exist on type ‘HTMLProps’" error with TypeScript, we should replace the for
prop with the htmlFor
prop.