我正在尝试将注释的TSDoc标准应用于用Typescript编写的React项目(着眼于用Typedoc生成文档),但是找不到任何关于注释React props对象的首选方式的明确答案。到目前为止,我已经得到了这个,其中MyProps是一个接口:
/**
* Description of my function component
* @param props - React props
*/
export default function MyComponent(props: MyProps) { ...有没有更好的方法?
发布于 2021-02-20 01:28:57
您希望记录props接口,而不是组件本身。这意味着这与documenting fields of an interface.是相同的
import React from 'react'
interface FooProps {
/** Testing 123 */
foo: string
}
function Foo({foo}: FooProps) {
return <>{foo}</>
}
<Foo foo="bar" />当您将鼠标悬停在最后一行的foo=上时,您应该会看到文档。

https://stackoverflow.com/questions/66281986
复制相似问题