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

git - TortoiseGit does not show commit log properly -

python - Getting ESC characters and non-printables from UDP socket / buffer -