reactjs / reactjs/react-docgen
Handling prop defined in the argument list of stateless components
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
Dear all,
I'm struggling to find documentation about handling a case in which you're defining props in the arguments passed to a stateless, functional component, i.e. ES6 destructuring assignment syntax. An example:
const SomeComponent = ({ propA, propB, propC = 'someString', propD = false}) => {}
The most similar to what I'm looking for is https://github.com/reactjs/react-docgen/issues/69.
Now, docgen returns a list of props-defined-as-arguments as long as they have a default value specified, the rest is straight ignored.
My question: is some work being done on this? Any documentation I can find in this regard?
It seems fair and logical that it's hard to infer anything (but the name) from those props that have no explicit default value attributed to them, but as it stands even the types of the props that are initiated in the arguments, are omitted. You just get a stringified value for whatever is passed to them.
Thanks in advance!
Edit: tapped into the discussion on deprecating defaultProps -- https://github.com/reactjs/rfcs/pull/107#issuecomment-644582699
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the behavior described in react-docgen issue #69 and the linked discussion about deprecating defaultProps. Then locate the component-prop extraction entry point and determine how destructured function arguments are handled. Done means documenting or supporting the requested prop names and available type information for this syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- documentation, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100