I am new to TypeScript, and rewriting an arrow function in React.js.
This is what it currently looks like:
handleChange = (event): void => {
const target = event.target || event.srcElement;
this.setState({
value: target.value
});
};
handleChange() doesn't return anything and only mutates state, so it's type is set to void.
What types should event and target have in this scenario? I need to support the widest range of browsers possible and so this is why target could be event.target or event.srcElement, if event.target is undefined.
Any help on this would be greatly appreciated.
UPDATED FUNCTION:
handleChange = (event: React.ChangeEvent<HTMLInputElement>): void => {
this.setState({
value: event.target.value
});
};