Dictionary 反应:如何从映射函数中获取项目宽度

Dictionary 反应:如何从映射函数中获取项目宽度,dictionary,reactjs,Dictionary,Reactjs,我是反应新手,我不知道如何从反应贴图函数中获得每个项目的宽度。它只返回一个react元素,没有js函数 例如: this.props.children.map((child, index) => { console.log(child.clientWidth); }) 请告诉我。 thx.使用返回 this.props.children.map((child, index) => { console.log(child.clientWidth); retur

我是反应新手,我不知道如何从反应贴图函数中获得每个项目的宽度。它只返回一个react元素,没有js函数

例如:

this.props.children.map((child, index) => {
    console.log(child.clientWidth);
})
请告诉我。
thx.

使用
返回

this.props.children.map((child, index) => {
    console.log(child.clientWidth);
    return child.clientWidth
})

对不起,您误解了我的意思,我的意思是我不能使用“clientWidth”或其他js函数,“child”实际上是一个React元素,它不提供这些函数。我想我需要将js代码放入react生命周期,比如“componentDidMount”,但我在项目中使用async请求,结果返回空。