DEV Community 👩‍💻👨‍💻

Ismail PE
Ismail PE

Posted on

Multiple api calls even for single saga action?

I was facing this issue in my React app and I could not find the exact reason in internet. There were many hacks and solutions for the same symptom, but nothing worked for me. Finally i solved it by correcting a mistake in code. So thought of posting it here.

I had an action which fetches a data via api call. There were other actions also defined inside same saga file. And this saga was used in multiple containers. Whenever i navigate between these containers, and call any action from this saga, there were multiple api calls triggered. But saga was called only once.

While injecting the saga, I was using different key names inside different containers for the same saga. Saga was supposed to automatically ignore the duplicate actions. But since the key was different, it considered all the calls as unique.

I used same key for this saga in all the containers where this was injected. So simple.

It was totally my mistake to use different keys. But i found same question in forums and github issues. So may be this would help someone to solve the issue or rule out this reason for the symptom.

Thank you.

Top comments (0)

Timeless DEV post...

How to write a kickass README

Arguably the single most important piece of documentation for any open source project is the README. A good README not only informs people what the project does and who it is for but also how they use and contribute to it.

If you write a README without sufficient explanation of what your project does or how people can use it then it pretty much defeats the purpose of being open source as other developers are less likely to engage with or contribute towards it.