Here is the case - for simplicity lets say my app consists from 5 pages (real situation is little more complex). Logically they are on one level. User may switch these 5 pages any way he wants and he can open any of these pages more than once. So lets say user opens pages in this order:
page1 -> page2 -> page4 -> page2 -> page4 -> page2
Every time I just push the new page in the Navigator, so the pages array becomes larger and larger even there are just 5 pages. The idea behind this is when user presses back button to go back logically in same order as pages were pushed, so show page2 and page4 two times again. The problem is all these pages stay in DOM too (I use React) and potentially DOM may become unnecessarily large. Is there are proper way to solve this issue? Maybe reset Navigator at some point to some reasonable amount of pages in the history? What about DOM?