Suppose we\'re defining a React class that will display a tree.
React.createClass({
propTypes: {
tree: treeType
},
render: function () {
I created recursive prop types something like this and it worked for me. Let me know if it works for you as well. lazyTreeType function will be called as many times as there is a sub in the object.
const lazyTreeType = () => some_props;
const some_props= PropTypes.shape({
date: PropTypes.string,
updated: PropTypes.string,
name: PropTypes.string,
sub: PropTypes.arrayOf(lazyTreeType),
type: PropTypes.string,
});
const component_proptype = PropTypes.shape({
id: PropTypes.string,
sub: PropTypes.arrayOf(some_props),
});