reactjs / reactjs/react-docgen

react-docgen is not compatible with react-like libraries

Open
#96 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

There are some react-like libraries such as react-lite, preact-compat and other which use API of React for components including PropTypes. All react-docgen methods work well with these libraries. But [this module](react-docgen disables work with react-like libraries) disallows using it.

I have a preact-compat component:

import { h, Component, PropTypes } from 'preact-compat';

export default class MyComponent extends Component {
  render() {
    return <div>{this.props.children}</div>;
  }
}

MyComponent.propTypes = {
  myProp: PropTypes.func
};

Actual react-docgen returns this value for type of myProp:

{
  name: 'custom',
  raw: 'PropTypes.func'
}

If I add preact-compat to whitelist react-docgen returns expected result:

{
  type: 'func'
}

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 locating the module that restricts React-like libraries through a whitelist, then reproduce the issue with the provided preact-compat component. Verify the existing behavior for PropTypes.func and compare it with the expected output; done means react-like libraries produce the same type information without being explicitly whitelisted.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
documentation, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.