Ngrx Store Resets after browser refresh. How to make the application preserve the state?

Viewed 27441

I Dispatch a action from one component

this.store.dispatch({type : STORE_TEAMCREST , payload : team.crestURI});

and in the other component i select from the store using

this.store.select(state => state.table.teamCrest).subscribe(data => this.teamCrest = data);

This works fine if my app is going sequentially backward or forward, but once i do a browser refresh the state loses it's value. How to preserve it's value so that it works on browser refresh?

2 Answers

Here is a cool medium article. This guy wraps the default create reducer function with a rehydrate one which saves data to local storage.

P.S. In case of ts errors check the comments of the article.

Related