Which one should I use useCallback() or move the component outside the function?
React - TSX
I have an component that makes multiple api calls one for getting a stuff A then another for getting stuff related to that stuff A and another for getting some other things related to A.
Right now i am not using callbackhook or moving the component outside I am ignoring the warning [exhaustive deps]
the functions that are declared inside the components update the state of the component like putting multiple kinds of data into various states. the options I have are:
Option 1: Move the function outside the component (at the top) and pass all the setState functions as callbacks which make function signature messy.
Option 2: useCallback hook which kind of cache the function but if i use option 1 I can avoid this completely. By using Option 2 i can kind of keep the function signature clean.
I have read the other post where they asked the same question but the answer didn't clarify my doubts.
If my states are tightly integrated with the functions then should I move it outside the component? or should I use the usecallback hook?