您可以为每个孩子使用displayName,可通过以下类型进行访问:
for (child in this.props.children){ if (this.props.children[child].type.displayName != 'Card'){ console.log("Warning CardGroup has children that aren't Card components"); } }
您可以为每个孩子使用displayName,可通过以下类型进行访问:
for (child in this.props.children){ if (this.props.children[child].type.displayName != 'Card'){ console.log("Warning CardGroup has children that aren't Card components"); } }