I want to delete or destroy my localStorage content whenever I route to a different component. I want to achieve this so as to avoid the localStorage variable from storing previous values even tho new values are coming in.
Am I on the right path?
Game Component
export class Game implements OnDestroy{
constructor(){
this.currentGame = JSON.parse(localStorage.getItem('currentGame'));
}
ngOnDestroy(){
this.currentGame = null;
}
}