How to use refs in React with Typescript

前端 未结 15 1482
闹比i
闹比i 2020-11-28 05:03

I\'m using Typescript with React. I\'m having trouble understanding how to use refs so as to get static typing and intellisense with respect to the react nodes referenced by

15条回答
  •  情书的邮戳
    2020-11-28 05:34

    Just to add a different approach - you can simply cast your ref, something like:

    let myInputElement: Element = this.refs["myInput"] as Element
    

提交回复
热议问题