Is it possible to use a property of a PropType shape as the prop type for another component?
E.g.
function App({ data}) {
return(
<div>
<Item item={data.item} />
</div>
)
}
const appPropTypes = PropTypes.shape({
foo: PropTYpes.string.isRequired,
item: PropTypes.string.isRequired,
});
App.propTypes = {
data: appPropTypes;
};
function Item({ item }) {
return <div>{item}</div>
}
Item.propTypes = {
item: , // How can I refer to appPropTypes.item here?
}
Obviously the example above is very simple.
But in my actual use case, item is much more complex and I'd like to avoid having to have duplicate code in appPropTypes and itemPropTypes