Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

143
Views
Sort order of response elements in redux toolkit

I'm looking to display a list of elements and let the user select some elements from this list. How can I make the selected items (from selectedIds) go in the beginning of that list. Can we use transformResponse for that? Or should it be done in the component?

Here is the call using redux-toolkit

export const exApi = api.injectEndpoints({
    endpoints: (builder) => ({
        getEx: builder.query({
            query: ({ type }) => `/exemple?type=${type}`,
            transformResponse: (response: { results }) => response.results,
        }),
    }),
});

export const { useGetExQuery } = exApi;

And here is the component

const { selectedIds } = props;
const { data: results } = useGetExQuery({ type: "tags" });

return (
  <FlatList
    data={results}
    renderItem={({ item }) => (
      <DisplayElement
        key={item.id}
        item={item}
        isSelected={selectedIds?.includes(item.id)}
        onPress={() => onPress(item.id)}
      />
    )}
  />
);
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!