3

I thought react/Vue/angular was used to build single page web app.

But why the hell are we losing components state when we navigate between routes?

Comments
  • 2
    Did you check whether it pushes route or pops it in navigation stack? When you push to navigation, according component is expected to being set up from scratch. When you pop, previous route's component state should remain intact, as state of other components in stack.
    Problem may be lying in that these routes come as siblings and none of them is child of another, thus effectively replaced.
  • 1
    @vintprox no

    I'm just using traditionnal router-link
  • 1
    Did you inject a state service or the router into your smart component in angular? You are responsible for state commutation there as well.
  • 1
  • 4
    @Afrographics
    No idea why you're calling out react and angular then 🤣
  • 3
    Or you could have a top-level component that never unmounts, holds the global state, and passes it as props to the <router-view>. Thats my fav approach
  • 1
    This is expected, if you want to persist state between component then use vuex. If you want every state to persist then you have software design problem
Add Comment