我在子组件中有下面的 JSX。
<td>
<div>
{this.props.image_element}
</div>
</td>
我function
在父组件中如下所示
image_element= (image_name) => {
if(image_name) {
this.update_photostatus('image');
}
else {
console.log('hello');
this.update_photostatus('input');
}
}
和
update_photostatus = value => {
this.setState({photostatus: value});
}
我得到的输出console
如下
和