How to use refs in React with Typescript

前端 未结 15 1481
闹比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:21

    If you wont to forward your ref, in Props interface you need to use RefObject type from import React, { RefObject } from 'react';

提交回复
热议问题