1

I am using the go_router package for routing and everything is working unless 1 router whenever I try to go to that router the redirection method of go_router is being called multiple times, Does anyone know the reason

How to minimize the call of redirection method?

Cavin Macwan
  • 1,183
  • 5
  • 12

1 Answers1

0

I am not sure if you managed to solve this but putting this out in case someone else runs into this.

In my case this happened because I hade redirection implemented in two different places, top-level and route-level

I had the 3 below paths:

  • /home
  • /profile_form

In top-level redirection I implemented the following:

if(user.validProfile==false)
  return '/home'

in /home path-level redirection i implemented the following

if(user.validProfile==false)
 return '/profile_form'

The issue stems from the fact that any route request goes Through top level redirection, every time, even if it came from a redirection.

I had this loop /home -> /profile_form ->/home -> /profile_form ...

I resolved this by ensuring redirection happens at the top level whenever possible,

I also drew all the links between the routes, it should be a Direct Acyclic graph taking into account the contol logic ofc, regardless of condition.

hope this helps

Wissam Y. Khalil
  • 133
  • 1
  • 5
  • 13