我正在尝试将参数(项目,它是 FlatList 中的数据项)传递给道具中的箭头函数。Popover 是一个 react-native-ui-kitten 元素。我的代码如下:
function PostRenderItem({ item }){
const [deleting, setDelete] = useState(false);
//item is accessible at this point
return(
//item is accessible at this point
<Popover
visible={deleting}
anchor={(item) => {
return(
<Text>{item.content}</Text>
//item undefined at this point
)
}}>
<Button>Delete me!</Button>
</Popover>
)
};
这里的问题是item
在声明为锚道具的箭头函数中未定义。这里的正确解决方案是什么?