Query Regarding React Router Behavior and API Loading Patterns #11453
Unanswered
babthamotharan
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I'm currently diving into React Router, and I've set up my routing structure as follows:
In my setup, the rootLayoutLoder function is responsible for calling an API to gather some common information used by both the Teacher and Student components. Meanwhile, the commonPageLoder function is calling an API based on the location path to fetch specific data.
Now, here's the issue I'm encountering: When I'm in the "/teacher" route and click the "Teacher" link, it triggers both the rootLayoutLoder and commonPageLoder functions. How can I prevent this double loading behavior while still ensuring the necessary data is fetched appropriately?
Looking forward to your insights and suggestions.
Best regards,
Thamotharan G
Beta Was this translation helpful? Give feedback.
All reactions