如何在React中从数组中检查prop对象的键?

时间:2017-06-19 22:29:01

标签: reactjs react-proptypes

使用以下代码,我可以检查传入道具的类型,但是如何检查阵列资产中每个对象的内部?

import numpy as np

a = np.array([[1 ,0.42, 0.78], [0.42, 1, 0.73], [0.78, 0.73, 1]])
# k=1 excludes diagonal correlation is 1 
np.where(np.triu(a > 0.7, k=1))

例如,如果我想检查AssetsTable.propTypes = { assets: PropTypes.array.isRequired }

enter image description here

1 个答案:

答案 0 :(得分:4)

我认为你可以做点什么

React.PropTypes.arrayOf(
  React.PropTypes.shape({
    id: React.PropTypes.string.isRequired
  })
).isRequired

有关详细信息,请参阅here