Related to the previously discussed issue with the transition hooks, I made several changes to the router implementation.
The transition() function has been moved from the RouterStore to the separate TransitionState class. A new instance of the TransitionState object is created whenever routing occurs.
If we preserve a fromState during a transition, calling exit hooks can be problematic and lead to an infinite loop, so we should check that they are executed only once.
Still, we have to be aware that because of the recursive implementation of the transition, infinite loops and therefore, stack overflow, can still be caused by a developer. To avoid infinite loops, a simple check has been added and an exception will be thrown whenever an infinite loop is detected.
I have been using the new implementation for a few days on a moderately large project. All tests are passing, the old and new ones.
Related to the previously discussed issue with the transition hooks, I made several changes to the router implementation. The
transition()
function has been moved from theRouterStore
to the separateTransitionState
class. A new instance of theTransitionState
object is created whenever routing occurs. If we preserve afromState
during a transition, calling exit hooks can be problematic and lead to an infinite loop, so we should check that they are executed only once. Still, we have to be aware that because of the recursive implementation of the transition, infinite loops and therefore, stack overflow, can still be caused by a developer. To avoid infinite loops, a simple check has been added and an exception will be thrown whenever an infinite loop is detected.I have been using the new implementation for a few days on a moderately large project. All tests are passing, the old and new ones.