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

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -

angular - DownloadURL return null in below code -