如何接收孩子的孩子?

问题描述 投票:0回答:1

我想跳过一个子封装以直接访问孙子。

this.props.children.map((x) => ...);

上面的示例用于循环父级的子级...但是我如何遍历孩子们的孩子?

我试图访问孩子的孩子,但这给了我一个未定义的例外。

this.props.children.map((x) => return x.children);
javascript reactjs react-native
1个回答
0
投票

您尝试过这个吗?

this.props.children.map((x) => return x.props.children);

也许您必须访问子级属性才能访问其子级。

© www.soinside.com 2019 - 2024. All rights reserved.