Skip to content

Commit

Permalink
fix: use toSorted() to copy & sort instead of slice().sort() (#3247)
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicamcinchak authored Jun 5, 2024
1 parent 0329997 commit dede865
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions editor.planx.uk/src/pages/Team.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,11 @@ const Team: React.FC = () => {
.getFlows(teamId)
.then((res: { flows: any[] }) => {
// Copy the array and sort by most recently edited desc using last associated operation.createdAt, not flow.updatedAt
const sortedFlows = res.flows
.slice()
.sort((a, b) =>
b.operations[0]["createdAt"].localeCompare(
a.operations[0]["createdAt"],
),
);
const sortedFlows = res.flows.toSorted((a, b) =>
b.operations[0]["createdAt"].localeCompare(
a.operations[0]["createdAt"],
),
);
setFlows(sortedFlows);
});
}, [teamId, setFlows]);
Expand Down

0 comments on commit dede865

Please sign in to comment.