Stateless function components without React.createElement or JSX?

Open
#70 4 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Start by tracing the existing stateless function component detection in react-docgen and reviewing tests for components using React.createElement. Compare the proposed propTypes heuristic against React.DOM helpers and React.createFactory cases; done means these components are detected without breaking existing detection behavior and tests cover the supported patterns.

Written by the indexing model from the issue text.

Description

react-docgen is unable to find stateless function components that don't contain JSX or React.createElement call expressions.

This might be the case when some helper library is used. This will also fail if the official React.DOM helpers are used (https://github.com/reactjs/react-docgen/pull/71). Another failing case would be if only React components are returned, but React.createElement was never called because the components were wrapped in React.createFactory.

What about adding support for another heuristic, such as having a propTypes property (and to be even more specific, a propTypes property with an object containing React.PropTypes entries).

I'm happy to implement this and add tests if this sounds reasonable to the maintainers.

Dominant language
TypeScript
Stars
3.8k
Forks
316
Avg merge
3h 28m
Merged PRs (30d)
6

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.

More from reactjs/react-docgen

All issues in reactjs/react-docgen

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.