reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.03k stars 7.53k forks source link

Add samples) react components with JSDocs! #1328

Open guledali opened 5 years ago

guledali commented 5 years ago

jsdoc-comment

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/** jsdoc-autofill

That's way I think reactjs docs should provide examples on this

SandroMiguel commented 4 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 }) {...}