React.js (useState ,useEffect) infinite loop error when setState("updated value") is called
Don't call setState
inside of the component body. It will update every time the component re-renders. That's why you are getting an infinite loop of state updates.