reactjs - React propTypes: objectOf vs shape? -


what's difference between proptypes.objectof , proptypes.shape? in docs:

  // object property values of type   optionalobjectof: proptypes.objectof(proptypes.number) 

vs

    // object taking on particular shape     optionalobjectwithshape: proptypes.shape({       color: proptypes.string,       fontsize: proptypes.number     }) 

when should use objectof , when should use shape?

proptypes.objectof used when describing object properties same type.

proptypes.shape used when describing object keys known ahead of time, , may represent different types.


Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

python 2.7 - Given three nested dictionaries, sort the top two nested dictionaries from a value in the innermost dictionary? -