Is there a straightforward way to sort a useQuery
query result?
#1169
-
When trying to sort <>
{posts
.sort(...) // sort on the updatedAt field
.map(
({ id, name, updatedAt }) =>
id &&
name &&
updatedAt && (
<PostCard
key={id}
name={name}
id={id}
updatedAt={updatedAt}
/>
),
)}
</> results in some behavior I didn't expect. Rather than sorting, one React then confirms with this error:
Would love to know if this is an issue with something I'm doing or an issue with GQty 🙂 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Array |
Beta Was this translation helpful? Give feedback.
Array
.sort
mutates the array trying to be sorted, so that's the first issue you are going to encounter, you can't sort the proxies returned by gqty, you can create another array and then sort that array, but not directly the one returned by the gqty client