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

141
Views
Selected item in createApi generated reducer

Currently, I have successfully built a redux-toolkit api using following code:

const api = createApi({
  reducerPath: 'api',
  baseQuery: baseQueryWithReauth,
  endpoints: (builder) => ({
    getClusters: builder.query({
      query: ROUTES.CLUSTERS,
    }),
  }),
})

The data Im receiving from backend looks like this:

  [
    {
      "name": "test 1",
      "description": "test 1",
      "id": 1
    },
    {
      "name": "test 2",
      "description": "test 2",
      "id": 2
    }
  ]

The user should be able to select one of these items through the interface, and the selection should be saved at redux. Something like:

{
  "data": [
    {
      "name": "test 1",
      "description": "test 1",
      "id": 1
    },
    {
      "name": "test 2",
      "description": "test 2",
      "id": 2
    }
  ],
  "selectedItem": 1 // Saved selected item id in redux so I can use it globally!
}

I have tried using createEntityAdapter and adding the selectId adapter, but seems not supported (I dont even know if its the correct approach). Is there any way to do it using redux-toolkit capabilities?

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!