Open guledali opened 5 years ago
My 2 cents
/**
* Sidebar component.
*
* @param {object} props - Props.
* @param {string} [props.className = ''] - Class name.
* @param {object[]} props.items - Sidebar items.
* @param {string} props.items[].title - Title.
* @param {string} props.items[].url - URL.
* @param {boolean} props.items[].active - Active.
* @param {object} props.onItemClick - Item click function.
* @example <Sidebar className={style.sidebar} items={sidebarItems} onItemClick={handleLinkClick} />
*/
export default function Sidebar({ className = '', items, onItemClick }) {...}
Please add samples on JSDocs with react, a lot programmers including me need IntelliSense and other benefits like auto-completion and type-checking as well. Migration over to TypeScript is not ideal if you have large code base. Adding a JSDoc comment is the easiest way of getting a lot of TypeScript tooling without configuring any code at all. On top of that vscode already supports it just by turning on in the settings
"javascript.implicitProjectConfig.checkJs": true
It even provides comment template for JavaScript functions when you type
/**
That's way I think reactjs docs should provide examples on this