Specifying onClick event type with Typescript and React.Konva

后端 未结 5 631
借酒劲吻你
借酒劲吻你 2021-02-04 23:02

I\'m trying to get rid of my tslint error Type declaration of \'any\' loses type-safety. but I\'m struggling to figure out what the correct type would be for the Ev

5条回答
  •  情书的邮戳
    2021-02-04 23:53

    You should be using event.currentTarget. React is mirroring the difference between currentTarget (element the event is attached to) and target (the element the event is currently happening on). Since this is a mouse event, type-wise the two could be different, even if it doesn't make sense for a click.

    https://github.com/facebook/react/issues/5733 https://developer.mozilla.org/en-US/docs/Web/API/Event/currentTarget

提交回复
热议问题