How to document react compound components using JSDoc?

问题描述 投票:0回答:0

如何正确记录复合成分?

我有这个子组件

/**
 * A React component that provides help text to the user.
 * @typedef HelpText
 * @type {typeof HelpText}
 * @param id - The ID of the help text element (required).
 * @param text - The text message to display (optional).
 * @param cssClasses - The CSS classes to apply to the help text element (optional).
 * @param children - The child component(s) to include in the help text element (optional). could be used instead of text prarameter.
 * @returns A memoized div element with the specified ID and CSS classes, containing the text and/or child component(s).
 */
const HelpText: React.FC<IHelpText> = ({
  id,
  text,
  cssClasses = "form-text",
  children,
}) => {
  return (
    <div id={id + "-helpText"} className={cssClasses}>
      {text}
      {children}
    </div>
  );
};


export default HelpText;

当我悬停它时,我可以正确地看到它的文档

我想把它变成一个复合组件的孩子

import HelpText, { IHelpText } from "../HelpText";


interface IFormTestProps {
    children: React.ReactNode;
  }


  const FormTest: React.FC<IFormTestProps> & { HelpText: React.FC<IHelpText> } = ({ children }) => {    
    return (
    <>
        {children} 
    </>
    );
};

 FormTest.HelpText = HelpText;

export default FormTest;

如何正确记录 FormTest.HelpText?

javascript reactjs documentation jsdoc
© www.soinside.com 2019 - 2024. All rights reserved.