Skip to content

Commit

Permalink
fix: react-docgen clean quotes on default value
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed May 17, 2021
1 parent c45a3e6 commit 237df70
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions props-info/react-docgen/src/transform-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const rdPropToCCProp = (rdProp: RdPropInfo): PropType => {
}
if (rdProp.defaultValue !== null && rdProp.defaultValue !== undefined) {
prop.defaultValue = rdProp.defaultValue.value ?? rdProp.defaultValue;
if (typeof prop.defaultValue === 'string') {
prop.defaultValue = cleanQuotes(prop.defaultValue);
}
}
let type: Partial<TypeInformation> = {};
if (rdProp.type) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ are all optional.",
},
},
"optionalEnum": Object {
"defaultValue": "News",
"description": "You can ensure that your prop is limited to specific values by treating
it as an enum.",
"type": Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ MyComponent.propTypes = {

MyComponent.defaultProps = {
optionalNumber: 21,
optionalEnum: 'News',
};

export default MyComponent;

0 comments on commit 237df70

Please sign in to comment.