Reputation: 1973
I have the following function:
createComment = (e: Event) => {
if (e.key === 'Enter') {
e.preventDefault()
...
}
}
but Flow is returning this error Property key is missing in Event
. How do I resolve this?
Upvotes: 1
Views: 788
Reputation: 33994
You should use SyntheticKeyboardEvent instead of Event
So change
createComment = (e: Event) => {
if (e.key === 'Enter') {
e.preventDefault()
...
}
}
To
createComment = (e: SyntheticKeyboardEvent<HTMLButtonElement>) => {
if (e.key === 'Enter') {
e.preventDefault()
...
}
}
Upvotes: 1