I'm using the following code to pass data to a route:
this.router.navigateByUrl('/myurl/goes/here', { state: { data: someData });
Now in the component i navigate to, i use the following code to get the data i passed from the first component.
this.incomingData = window.history.state.data;
Now the issue arrises when I reload the second component (Component B), i get an error telling my the data I passed to it is now undefined. (this.incomingData becomes undefined).
Is what am doing the correct way to pass and receive data between components or am I doing something wrong ?