我想跳过一个子封装以直接访问孙子。
this.props.children.map((x) => ...);
上面的示例用于循环父级的子级...但是我如何遍历孩子们的孩子?
我试图访问孩子的孩子,但这给了我一个未定义的例外。
this.props.children.map((x) => return x.children);
您尝试过这个吗?
this.props.children.map((x) => return x.props.children);
也许您必须访问子级属性才能访问其子级。