Is this overusing of hooks or am I paranoid ?
During my reactjs journey I always was puting inside hooks function which requires either access to props/state or they have to somehow use other hooks.
Recently I join to the project where people (who are backend developers mainly) were putting inside hooks functions which does not requires any of those hooks stuff i decribed above. Like for example they were building two function incrementDate(date) and decrementDate(date). All those function requires is date. They are puting this inside hooks and using useEffects on this. Is this big anti-pattern or am I paranoid?
3 Replies
If they are creating reusable code which can be easily maintained?
I don't see a problem here.
Provided they invoke use effect properly
but then if you have hooks which returns pure function only then you have another hooks which has to have those function in use effect
and you are getting cascade useEffect depenendecy on fuction which does not to be hooks a tall
at all
Hence why I said it's not a problem provided they are using hooks properly
Not a problem separating the functions for maintainability/reusability