reactjstypescriptvisual-studio-codejsdoc

React.memo() prevents jsdoc description to show up in vscode, is there a work around?


When exporting my component like this

export default React.memo(MyComponent);

and using it somewhere else like this

<MyComponent></MyComponent>

it will not show the jsdoc documentation of the component but only "import MyComponent"

BUT

export default MyComponent;

will show the full jsdoc documentation when used somehwere else like this

<MyComponent></MyComponent>

does anybody know how to solve this ?


Solution

  • Put the doc comment on the (default) export itself, not on the memo-ised component - and maybe don't even declare that separately:

    /**
     * My doc comment
     */
    export default React.memo(function MyComponent(props) {
        return <>…</>;
    });