wrap use-query in hooks?
Hi There,
Let's say I have an entity Post, I would normally make a useGetPosts() hook and a usePostPosts() hook. But would it be a better idea to just make one usePosts() where I export the useQuery and useMutation? Or should thoose two modules be separated into it's own hooks?
5 Replies
eastern-cyanOP•4y ago
Or would it be bettier to create the two hooks, and then export them in one hook in order to uphold the S.O.L.I.D princinple?
harsh-harlequin•4y ago
Personal opinion I have found that it is better when you separate them and if there are issues with it, makes it easier to debug it
eastern-cyanOP•4y ago
Separate it into two and then stop there, or export them from one hook? I guess I may have been damaged from OOP 😄
any body else who have some thoughts about this?
fascinating-indigo•4y ago
I personally prefer separating them. So one hook for a query and one hook for a mutation
sunny-green•4y ago
Separate them
Maybe you want to use useGetPosts elsewhere. If they are separated it makes re-usability easier