I'm puzzled as to why I keep encountering a TypeError with this code. Is there something obvious that I'm overlooking?
export const selectAllUsers = createFeatureSelector<ReadonlyArray<User>>('users');
export const selectUser = () =>
createSelector(selectAllUsers, (users) => {
return users.find(
(user) =>
user.name === "Mr.Doe"
)});
This scenario is reminiscent of the Book example in the ngrx walkthrough and triggers the following error in the browser console:
ERROR TypeError: users.find is not a function
selectUser user.selector.ts:13
memoizedProjector ngrx-store.mjs:697
While I am able to retrieve my user using selectUser, it's perplexing to see this error. It feels like there might be something crucial missing in typescript or store selectors.
Tested on both firefox and chrome browsers running on Linux.
Here are the dependencies from package.json:
"@angular/animations": "~13.1.2",
"@angular/cdk": "^13.1.2",
"@angular/common": "~13.1.2",
"@angular/compiler": "~13.1.2",
"@angular/core": "~13.1.2",
"@angular/forms": "~13.1.2",
"@angular/material": "^13.1.2",
"@angular/platform-browser": "~13.1.2",
"@angular/platform-browser-dynamic": "~13.1.2",
"@angular/router": "~13.1.2",
"@ngrx/store": "^13.0.2",
"@ngrx/store-devtools": "^13.0.2",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
"zone.js": "~0.11.4"`
Edit 1: ERROR TypeError: user.find -> users.find
Edit 2: The user state only contains users (players), here is a screenshot taken from devtools, the names are different, hence the typo above