reactjs / reactjs/react-docgen

Can I "get" the intended HTML element to be rendered?

Open
#566 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
5h 7m
Merged PRs (30d)
4

Description

I would like to document both the props and the HTML element that a react component plans on rendering:

const MyComponent = ({ foo, bar, ...restProps }) => <h1 foo={ foo } bar={bar}  {...restProps } />;

MyComponent.propTypes = {
   foo: PropTypes.string,
   bar: PropTypes.number,
}

In the above example I want to be able to document:

  1. The props stated in propTypes
  2. The "native" HTML props that would be valid for an h1 element.

In the docs i wanna say:
"here are the explicitly set props and this component also takes all valid props for HTMLHeadingElement"

Is it possible for us to get the h1 tag from docgen so we can associate that component's documentation with its html tag?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named; begin by locating the docgen parser or API that extracts React component metadata and its existing test coverage. Done means exposing the rendered native HTML tag alongside the documented prop information, with coverage demonstrating the h1 case.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
documentation
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.