【发布时间】:2021-04-25 21:27:52
【问题描述】:
当 imagePaths 是一个空数组时,我想通过三元运算符使 IconButton 不可见。但是我只想在数组包含这样的值时才显示iconButton:但是当我使用我的代码时,无论如何我都会看到iconButton。
如何修复我的代码?
这是我的代码
{imagePaths &&
<IconButton iconName="cancel" onPress={onRemoveImage} />
}
console.log(imagePaths);
// [] empty array
// ["SampleFile_1619356823623.jpg"] there is value in array
【问题讨论】:
标签: javascript node.js reactjs react-native