I have several large objects that I use in many components so I made a proptypes file for each large object like this:
PropTypes/PropLargeObject.js
which contains import PropTypes from "prop-types";
const PropLargeObject =
PropTypes.shape({
id: PropTypes.number.isRequired,
name: PropTypes.string.isRequired,
items: PropTypes.ArrayOf(PropTypes.Shape({
itemId: PropTypes.number.isRequired,
itemName: PropTypes.string.isRequired
}))
});
export default PropLargeObject;
I use the object in my components like this:
import {PropLargeObject} from "./PropTypes/PropLargeObject";
Component.propTypes = {
LargeObject: {PropLargeObject}
}
It gives me warning Prop type "PropLargeObject" is invalid it must be a function, usually from React.PropTypes. What am I doing wrong here?