What's the difference between PropTypes.objectOf
and PropTypes.shape
? In the PropTypes:
// An object with property values of a certain type
optionalObjectOf: PropTypes.objectOf(PropTypes.number)
vs
// An object taking on a particular shape
optionalObjectWithShape: PropTypes.shape({
color: PropTypes.string,
fontSize: PropTypes.number
})
When should I use objectOf
and when should I use shape
?