tomastrajan / angular-ngrx-material-starter

Angular, NgRx, Angular CLI & Angular Material Starter Project
https://tomastrajan.github.io/angular-ngrx-material-starter
MIT License
2.82k stars 918 forks source link

TypeError being thrown in ToDos and Stocks after fresh install #433

Closed daveburr closed 5 years ago

daveburr commented 5 years ago

Minimal reproduction of the bug with instructions:

After following the steps shown in the project's ReadMe, namely cloning the project, doing npm install, npm start, the app launches just fine in my browser. But when I go to the ToDos and start checking off to do's and unchecking them, after a short delay, I get this error popping up in my Dev Tools Console:

core.js:12584 ERROR TypeError: Cannot read property 'toLowerCase' of undefined
    at settings.selectors.ts:55
    at store.js:627
    at memoized (store.js:577)
    at defaultStateFn (store.js:596)
    at store.js:635
    at memoized (store.js:577)
    at MapSubscriber.project (store.js:512)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:35)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.Subscriber.next (Subscriber.js:54)
    at MapSubscriber.push../node_modules/rxjs/_esm5/internal/operators/map.js.MapSubscriber._next (map.js:41)

Expected behavior:

Expect to be able to add to do's, check them off, uncheck them and not have the app break because of a TypeError. Same problem also appears if you enter different ticker symbols in Stocks.

Other information:

I had cloned this project about a month ago, and don't recall seeing this problem. I deleted that original folder and started over with a clean install of the project to take advantage of the latest updates. The app "remembered" my prior to do's, so I don't know whether this problem is somehow related to the format of the local storage between the earlier version and this latest version. I'm not sure where to look for that to clear it out if that is the problem.

I would be willing to submit a PR to fix this issue:

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[X] No - I'm not sure what I'm doing yet!!

daveburr commented 5 years ago

For what it's worth, here's the configuration of my computer when this problem occurred: angular-ngrx-material-starter: 7.2.0 npm: 6.4.1 node: 8.11.4 Chrome Browser: 70.0.3538.77 MacOS: 10.13.6 I was not able to recreate the problem using Safari 12.0.1, but of course using a different browser creates a separate and independent record of the To Do's.

timdeschryver commented 5 years ago

I think this is indeed due to the fact that the local storage logic has been refactored. A fresh install wouldn't help because the todos are stored in your browser's cache.

You can see and clear the cache via:

image

Could you try to clear the cache? If everything is OK, the error should disappear.

daveburr commented 5 years ago

Hello Tim. Thanks for looking into this. Indeed, after clearing my local storage of the previous content, as you described above, the To Do's and Stocks functionality are both working correctly. I don't see the TypeError being thrown anymore.

OK, so I learned how the To Do's work with Local Storage and also learned more about Google's Dev Tools! Thank you! I think you can close out this issue.

timdeschryver commented 5 years ago

I'm glad to hear that!