Skip to content

Tag: reactjs

useEffect with many dependencies

I am trying to fetch employees and here is what I am trying to do using useEffect Here I want to achieve 2 goals: fetch adminEmployees if (adminEmployees===’unAuthorized’) then go to loginPage but when doing this as in the code, it creates infinite loop. How can I achieve the desired functionality…

how to use value of useState after init it

I these state hook: my medicalProblem variable will initial with response of a api : but I got this error: Answer There are a couple ways to accomplish this, but the easiest may be creating another useEffect hook that depends on the medicalProblems array as seen below! That extra hook will make sure your medi…