나의 배열체를 포함하는 몇 가지 정보를 제공합니다. 할 수 없게 렌더링하기 위해 나가고 싶고 도움이 필요합니다. 나는 그들을 렌더링이:
this.state.data.map(
(item, i) => <div key={i}> {item.matchID} {item.timeM} {item.description}</div>
)
이 가능한 정렬이 그들을 오름차순과 함께항목입니다.timem 에
에서는지도()
기능을 하거나 내가 그들을 정렬하기 전에 나는 사용할까요?
이 있'다시 찾고:
// ... rest of code
// copy your state.data to a new array and sort it by itemM in ascending order
// and then map
const myData = [].concat(this.state.data)
.sort((a, b) => a.itemM > b.itemM)
.map((item, i) =>
<div key={i}> {item.matchID} {item.timeM}{item.description}</div>
);
// render your data here...
방법은종류
이 변형되는 원래 array. 따라서 내가 만드는 새로운 배열을 사용하여concat
방법입니다.
this.state.data.sort((a, b) => a.item.timeM > b.item.timeM).map(
(item, i) => <div key={i}> {item.matchID} {item.timeM} {item.description}</div>
)