Home > Mobile >  The entity passed to the `selectId` implementation returned RTK Query
The entity passed to the `selectId` implementation returned RTK Query

Time:11-16

I used the code example from the official RTK query documentation

[console](https://img.codepudding.com/202211/6925053d29d1468bbe426555d37f041b.png)

[This solution didn't work for me](https://img.codepudding.com/202211/096d459949bd42c3806fc55dc22763fe.png)

CodePudding user response:

Entity adapter default expects the entity to have id for unique identification. In your case, as i can see, unique id of the user id named as _id.

Try the following way of explicitly setting the id:

const usersAdapter = createEntityAdapter({
  selectId: (user) => user._id,
});

Hopefully, that should fix the issue.

Thanks.

  • Related