Closed
Description
If there is a self-reference in propTypes define, docgen will throw an error: RangeError: Maximum call stack size exceeded
. related to #249.
For reproduction, copy the code below to the playground: https://reactcommunity.org/react-docgen/
import React, { Component } from 'react';
import PropTypes from 'prop-types';
/**
* General component description.
*/
class MyComponent extends Component {
render() {
// ...
}
}
MyComponent.propTypes = {
/**
* Description of prop "foo".
*/
foo: PropTypes.number,
/**
* Description of prop "bar" (a custom validation function).
*/
bar: function(props, propName, componentName) {
// ...
},
baz: PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]).isRequired,
child: PropTypes.shape(MyComponent.propTypes)
};
MyComponent.defaultProps = {
foo: 42,
bar: 21
};
export default MyComponent;