I can not figure out how to use the Focus event with React and Typescript:
private onFocus(event: FocusEvent) {
}
...
<div
tabIndex={0}
onFocus={this.onFocus}
>
Element
</div>
With the code above I get the following error
Types of property 'onFocus' are incompatible.
Type '(event: FocusEvent) => void' is not assignable to type '((event: FocusEvent) => void) | undefined'.
Type '(event: FocusEvent) => void' is not assignable to type '(event: FocusEvent) => void'.
Types of parameters 'event' and 'event' are incompatible.
Type 'FocusEvent' is not assignable to type 'FocusEvent'.
Property 'initFocusEvent' is missing in type 'FocusEvent'.
I tried a bunch of approaches to try to make the Typescript compiler happy but nothing seems to work.