-
-
Notifications
You must be signed in to change notification settings - Fork 311
Open
Labels
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
});michalstocki, AdamRudnicki96, jaroslawsawicki, dan-kez, carrickjason and 1 more