javascript - 我的函数如何知道我的 object.value,因为我传入了一个 void 参数?
问题描述
这是使用 Reactjs 创建组件的经典功能。
我还调用了一个函数来通过它们的“id”删除组件。我的组件使用解构数据。你会注意到我没有在我的函数调用中传递任何真正的参数,因为它是一个经典的争论“(id)”传递而不是解构参数“({id})”,我的函数如何知道我的对象的值? 因为删除有效!惊人。
这是我的功能:
return(
this.props.data.element.map(({id, title}) => {
return(
<li key={id} className="collection-item">
{title}
<i
className="material-icons"
// the delete will work !
// despite I pass a classic argument in
onClick={() => this.onSongDelete(id)}
>delete</i>
</li>
)
})
)
任何提示都会很棒,谢谢
解决方案
推荐阅读
- python - 当我输入 python 时,CMD 打开窗口存储
- awk - 如何在文本文件的所有行之间添加 N 个空行?
- node.js - 如何在 mocha 测试中存根 mongodb 的 addCursorFlag?
- android - Expo SDK 更新导致 Playstore 应用程序崩溃(无效 SDK 错误)
- sql - 在 SQL 中按分区对值进行排名
- php - 如何在我的新 Laravel 应用程序中下载在旧应用程序中创建的文件
- c++ - 将指针传递给结构时Qt信号不起作用
- python - 使用列名作为要替换的字符串值执行字符串替换
- google-apps-script - 如何在 Google 表格中返回重定向的 URL
- python - OPEN-CV 错误: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'