我如何使用 jsdoc 注释注释 React.forwardRef,以便智能感知可以显示底层组件? [英] How do i annotate React.forwardRef with jsdoc comments so that intellisense can show up for the underlying component?

查看:53
本文介绍了我如何使用 jsdoc 注释注释 React.forwardRef,以便智能感知可以显示底层组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以这种方式编写为函数的 React 组件:

I have a React component written as a function this way:

function Button({ text, icon }) {
  return ...
}

Button.propTypes = {
  text: PropTypes.string.isRequired,
  icon: PropTypes.string.isRequired
}

使用此组件时,我在 vscode 中获得自动完成/智能感知

when using this component, I get the autocompletion / intellisense in vscode

如果我将此组件包装在 React.forwardRef 中,导出默认 React.forwardRef((props, ref) =>

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆