-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crashes when DefaultProp isn't a string #1510
Conversation
Codecov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fix!
@@ -9,18 +9,19 @@ export default function renderDefault(prop: PropDescriptorWithFlow): React.React | |||
// Workaround for issue https://github.com/reactjs/react-docgen/issues/221 | |||
// If prop has defaultValue it can not be required | |||
if (prop.defaultValue) { | |||
const defaultValueString = typeof prop.defaultValue.value === 'string' ? showSpaces(unquote(prop.defaultValue.value)) : showSpaces(String(prop.defaultValue.value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we don't really need a condition here?
const defaultValueString = typeof prop.defaultValue.value === 'string' ? showSpaces(unquote(prop.defaultValue.value)) : showSpaces(String(prop.defaultValue.value)); | |
const defaultValue = showSpaces(unquote(String(prop.defaultValue.value))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that works too. Although I just realized if the defaultValue isn't a primitive type like an object it would probably show [object Object]
as the default prop?
EDIT: nvm if it's an object it gets evaluated correctly I guess
BTW if this gets merged to |
🎉 This PR is included in version 10.4.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@sapegin sorry to bother you but would it be possible to merge |
Styleguidist crashes when default prop isn't a string, e.g. a number.