Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

location.reload(true) is deprecated

I know that it is not ideal to reload an Angular Single Page Application. However there is a place that I need to reload the full application.

TSLint says that reload is deprecated.

Is there any alternative for this?

like image 420
Dilshan Liyanage Avatar asked Mar 12 '19 17:03

Dilshan Liyanage


People also ask

Is location reload deprecated?

Using location. reload() is the valid syntax. It is only the reload with forcedReload which is deprecated. In your case changing location.

What is location reload true?

True reloads the page from the server (e.g. does not store the data cached by the browser): window. location. reload(true); False reloads the page using the version of the page cached by the browser.

What does Window location reload () do?

Window location. The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

How do I stop Windows reloading my location?

You can use the following code: window. stop();


2 Answers

You can use location.reload() without the forceReload flag. This is just deprecated because it is not in the spec: https://www.w3.org/TR/html50/browsers.html#dom-location-reload

like image 178
Zachary Schroeder Avatar answered Oct 05 '22 15:10

Zachary Schroeder


If you look at interface definition for Location you will see the following:

/**   * Reloads the current page.   */ reload(): void; /** @deprecated */ reload(forcedReload: boolean): void; 

Using location.reload() is the valid syntax. It is only the reload with forcedReload which is deprecated.

In your case changing location.reload(true) to location.reload() to resolve your issue.

like image 21
Matt Seymour Avatar answered Oct 05 '22 15:10

Matt Seymour