reactjs / reactjs/react-docgen

HOC as a function won't get generated docs

Open
#205 9 comments 1 reaction 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

Similar to #177 but a slightly different scenario...

Given a HOC method like so:

import { bool } from 'prop-types';

const withSomeExtraProps = Wrapped => {
  class HigherOrderComponent extends Component  {
    static propTypes = Object.assign({}, Wrapped.propTypes, {
      /**
       * This should be picked up in the docgenInfo
       */
      anExtraProp: bool,
    });
    static defaultProps = Object.assign({}, Wrapped.defaultProps, {
      anExtraProp: false,
    });
    // ....the rest of the HOC logic
  }
  return HigherOrderComponent;
}

export default withSomeExtraProps;

I understand that this wouldn't automatically mean that the export default withSomeExtraProps(Wrapped) wouldn't automatically get the docgenInfo from the HOC added, but I thought individually this HOC would have it's own docgenInfo that I could reference on it's own.

However, it seems the inner component class here doesn't get recognised and parsed. Does the component class need to be exported for the parser to find it?

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

Start by reproducing the HOC example in the issue and trace how the parser handles the inner component class. Confirm the expected docgenInfo behavior and add coverage showing that the HOC's extra prop is recognized; the report names no files or existing tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation, tooling
Issue type
Bug
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.