如何反转具有关键唯一id的动态子列表的顺序?
React - How can I reverse the order of dynamic children lists that have a key unique id
https://jsfiddle.net/justindeal/8hqqgbuf/5/?utm_source=website& utm_medium = embed& utm_campaign = 8 hqqgbuf
有一个从数组创建的列表。我想把最新的条目放在最上面,而不是放在最下面。除了添加xxxxx之外,我找不到任何关于如何精细牙齿控制的内容。已经完成的键Id。
是代码示例。
var NotesList = React.createClass({
render: function () {
var notes = this.props.notepad.notes;
return (
<div className="note-list">
{
notes.map(function (note) {
return (
<NoteSummary key={note.id} note={note}/>
);
})
}
</div>
);
}
});
所以我想用一个常见的javascript方法,你可以通过map方法反转数组的顺序,它工作。
var NotesList = React.createClass({
render: function () {
var notes = this.props.notepad.notes;
return (
<div className="note-list">
{
notes.reverse().map(function (note) {
return (
<NoteSummary key={note.id} note={note}/>
);
})
}
</div>
);
}
});
相关文章:
- 如何在javascript而不是jquery中添加动态列表
- android phonegap jquery点击动态列表中的元素
- JSP中的动态列表框
- 使用PhoneGap和jQuery Mobile在android设备上显示动态列表视图
- JQuery Mobile UL列表仍然不能用于动态列表
- 将项目添加到动态列表
- 谷歌应用程序脚本web应用程序动态列表从表单
- 在动态列表中单击的特定img上执行JQuery
- 在jquery中滚动动态列表视图
- 无法更新复选框的动态列表
- 我无法将变量从动态列表传递到php页面进行处理.这是我不理解的逻辑问题吗
- 在 asp.net c# 中通过 POST 传递动态列表
- 将元素附加到动态列表,但浏览器不会刷新 UI
- 不使用排序数组的动态列表排序
- 基于 Javascript/jQuery 的带缩进的动态列表
- 带有动态列表的离子标签
- Jquery Mobile 中的动态列表视图和按钮
- 更改动态列表项的 CSS
- 无法使用JSON响应通过JQuery Mobile生成动态列表视图
- 使用AJAX和javascript将动态列表模型发布回控制器