Is a new instance created of the target when menu clicked?

Experimenting with some navigation methods and it seems that a new instance of a view component is created every time a view component is navigated to.
No state can be kept.
Reading the docs it states that a RouterLink does not reload… does this mean that an instance is kept and used when selected?

Hoping you follow what I am on about,

Thanks,
Paul Fraser

Reading the docs it states that a RouterLink does not reload

It does not reload shared components of the parent layout. If you have two views ViewA and ViewB that both have the parent layout MainView (which shows a sidebar for example), and you navigate from ViewA to ViewB then the MainView components (sidebar in this example) will not be reloaded. All components within ViewB however are reloaded.

no state can be kept

currently correct. If I recall correctly, this is being worked on. [Here]
(https://github.com/vaadin/flow/issues/3522) is a github issue about it.

Hi Paul.

The routerlink means that it will not reload in the browser, so there is no full refresh. That refresh would actually create another UI…

Currently the views and the state is not stored on the server when the view is no longer needed. This is due to saving memory (when should the view be discarded ?), and because it is usually be quite cheap to recreate it.

BUT, I know that it is not mayhaps always the case, so sometimes you would want to store the state and reuse it.
For now, you’ll have to do that in your application logic. It is most conveniently possible by using UI-scoped beans when using Spring/CDI. Without those, you’d have to implement something else that allows the same.

The preserve-on-refresh issue is kind of related to this, but I see it as slightly another use case because it is related to user opening another window/tab or refreshing the page.

Thus I created another issue about this: https://github.com/vaadin/flow/issues/5349
Please go +1 and comment on that if it describes something that you would want.

Thanks for response in the forum and raising issue #5349

I am having some success with creating view instances in an OSGi environment using code similar to that provided by Sandared where routes are developed using the OSGi PROTOTYPE scope. issue #5125

Without having a full knowledge of the flow system internals, I would like to know if I keep a reference to an instance created in OSGi can I navigate to it later rather than have a new instance created?

If so, how to navigate to it.