Support referenced and imported propTypes
tmc opened this issue ยท 7 comments
givent
import React from 'react';
const user = React.PropTypes.shape({
email_address: React.PropTypes.string,
name: React.PropTypes.string,
})
export default class Foobar extends React.Component {
static propTypes = {
a1: user,
a2: React.PropTypes.shape({
email_address: React.PropTypes.string,
name: React.PropTypes.string,
})
};
render() { return (<p>.</p>); }
};
the a1 field is renders to 'No Control available' while a2 appropriately renders the expected form.
Being in an environment in which I'm generating propTypes from an IDL this is a pretty important limitation.
Okay, let's wait for @chrisui to be back from holiday (soon?) and then we'll look into this! ๐
Would be an interesting contribution to https://github.com/reactjs/react-docgen
@fkling I'm curious about your thoughts on how easy/hard this would be. I would be happy to dig in and submit a PR.
Potentially the same issue as reactjs/react-docgen#65 . Variables should be resolved. I guess one would just have to add a resolveToValue
call here: https://github.com/reactjs/react-docgen/blob/master/src/handlers/propTypeHandler.js#L47