-
-
Notifications
You must be signed in to change notification settings - Fork 291
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
Expressions in propTypes not parsed correctly #36
Comments
Thinking about it more, I will have to check again if it is really a bug. It might also be that the But even then, it's probably better to leave |
I have the same problem, although my example is simpler. Given the following code: export default function Tooltip () { ... }
Tooltip.arrows = ['up', 'down', 'left', ...];
Tooltip.propTypes = {
arrow: PropTypes.oneOf(Tooltip.arrows)
}; And this generates the following JSON: {
arrow:
{ type: { name: 'enum', computed: true, value: 'Tooltip.arrows' },
required: false,
description: '' }
} |
Any further thoughts on this? I've recently run into the same problem with the following: const KIND = {
PRIMARY: 'primary',
SECONDARY: 'secondary'
};
// ...
static propTypes = {
kind: PropTypes.oneOf(Object.values(KIND))
}; I'd expect this: {
"kind": {
"type": {
"name": "enum",
"value": [{
"value": "'primary'",
"computed": false
}, {
"value": "'secondary'",
"computed": false
}]
},
"required": false,
"description": "",
"defaultValue": {
"value": "'primary'",
"computed": false
}
}
} However I'm getting this: {
"kind": {
"type": {
"name": "enum",
"computed": true,
"value": "Object.values(KIND)"
},
"required": false,
"description": "",
"defaultValue": {
"value": "'default'",
"computed": false
}
}
} Is there a workaround for this, or a fix in the works? If not, I'd be happy to look at submitting a PR to address this, if you could point me in the right direction. |
Originally reported in styleguidist/react-styleguidist#13 (comment).
I use an expression in
React.PropTypes.oneOf(...)
. This is the output fromreact-docgen
:coverWidths
is a variable defined in that file. In runtime it's generated correctly, butreact-docgen
can't parse it.value
in the marked line should benull
, and there should be araw
property with it instead.@fkling confirmed that this is is a bug in react-docgen.
The text was updated successfully, but these errors were encountered: