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

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -