reactjs / reactjs/react-docgen
Support Object.assign in propTypes definition
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 3.8k
- Forks
- 316
- Avg merge
- 5h 7m
- Merged PRs (30d)
- 4
Description
In my React App, I have components which pass receive properties but just pass them as is to their child component. The parent component sort of extends the child component properties, so I'm using Object.assign to avoid code duplication. Unfortunately, recat-docgen doesn't seem to handle propTypes values which are evaluated from a function.
For example, let's say I have a component named ParentComponent and a component named ChildComponent.
The render function of the ParentComponent looks like this:
render() {
return (
<ChildComponent childPropA="SomeValue" childPropB="AnotherValue" />
);
}
When I render the ParentComponent my code looks like this:
<ParentComponent parentPropA="Value" childPropA="SomeValue" childPropB="AnotherValue" />
Therefore, I use Object.assign for setting ParentComponent.propTypes:
ParentComponent.propTypes = Object.assign({}, ChildComponent.propTypes, {
parentPropA: React.PropTypes.string
});
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
No source file or test is named. Start by tracing how react-docgen evaluates component propTypes, then reproduce the Object.assign example from the issue. Done means inherited and locally defined propTypes are both extracted correctly, with a regression test covering the example.
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