In my react and typescript app, I use
interface Props {
text: String;
ok?: Boolean;
i?: number;
fn?: (bob: string) => string;
person: Person;
handleChange?: (e: React.ChangeEventHandler<HTMLInputElement>) => React.ChangeEventHandler<HTMLInputElement>}
How do I correctly define the typings for input handle change
return (
<div ref={divRef}>
<div>{text}</div>
<br />
<input
ref={inputRef}
onChange={ handleChange}
/>
</div> );
CodePudding user response:
Try this
interface Props {
// ...
handleChange?: (e: React.ChangeEvent<HTMLInputElement>) => void
}