Tab change runs useEffect hook all the time


I am using coreUI tabs as shown below.


In the cheques summary I need to run a request to fetch a collection of banks from the server. For that i wrote an axios GET request in useEffect(()=>{}, [ ]) hook in the cheques summary form.

But I can see that the post request is being run every time i go to other tabs as well.

Any ideas on how i can stop this behavior so that the GET request only triggers in the cheques summary


Im not an expert, i guess you are using react.
Are the tabs in a State? Every time you change the tab, you set the state. This makes the form to re render and run the hook again. You should create new state and set it true when tab is selected and indicate the effect to watch changes of this state to run:
useEffect(()=>{}, [tabSelectedCheques])
Add tabState inside . hope it helps