What are the disadvantages of refactoring multiple UseEffect into one?
I have used multiple useEffect for different callback functions. Now, I get to know that I can refactor multiple useEffect into a single one, all the callback functions have different dependencies so is it a great idea to refactor all useEffect into a single one or is there any better approach to optimise the code and no need to use of multiple useEffect or use of multiple useEffect is common practice?
Its depends on your dependencies (of your useEffect) and component , i think its better to split useEffect for each your concept , for example in one useEffect you have api call and in the other useEffect you have event listener and remove listeners and dependencies , because i think if you combine them , it may create unexpected re-render and side effect
Answered By – tmohammad78