let's consider two hook components:
export function HookCompA({a,b,c,d}){
...
useEffect(...,[x])
useEffect(...,[y])
functionA{...};
functionB{...};
functionC{...};
functionD{...};
...
}
export function HookCompB({a,b,c,e}){
...
useEffect(...,[x])
useEffect(...,[w])
functionA{...};
functionB{...};
functionC{...};
functionE{...};
...
}
Despite being so similar, due to the nature of the context, we have to consider these hooks as different components, however, there is a lot of duplicated code to refactor and they even share the same code for some effects.
Due to my experience with OOP, it is hard to imagine how to solve this issue without a callback to inheritance, which is not what hooks is all about. I neither think that just exporting the functions in another file and adding them to both hooks is the best idea.
I wish to know the best practice for reusing code in hooks, specially for effects.