📜  谷歌将英语翻译成西班牙语 - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:51.906000             🧑  作者: Mango

代码示例4
React propTypes: objectOf vs shape?

PropTypes.objectOf is used when describing an object whose properties are all the same type.

    const objectOfProp = {
        latitude: 37.331706,
        longitude: -122.030783
    }
    // PropTypes.objectOf(PropTypes.number)
    
    
PropTypes.shape is used when describing an object whose keys are known ahead of time, and may represent different types.

    const shapeProp = {
        name: 'Jane',
        age: 25
    }
    // PropTypes.shape({ name: PropTypes.string, age: PropTypes.number })