何时
children: PropTypes.string
显示错误
Failed prop type: Invalid prop `children` of type `object` supplied to `DetailField`, expected `string`.
何时
children: PropTypes.object
显示错误
Failed prop type: Invalid prop `children` of type `string` supplied to `DetailField`, expected `object`.
如果我尝试这样做,我不知道它是否有效
children: PropTypes.object && PropTypes.string
它显示
Failed prop type: Invalid prop `children` of type `object` supplied to `DetailField`, expected `string`.
我该怎么办?
答案 0 :(得分:2)
如果我对您的理解正确,则需要检查以下两种道具类型之一:对象或字符串:
children: PropTypes.oneOfType([
PropTypes.object,
PropTypes.string,
])
请查看prop-types README以获得更多信息。