alan2207 / bulletproof-react

🛡️ ⚛️ A simple, scalable, and powerful architecture for building production ready React applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shared/Common api location ?

ChambreNoire opened this issue · comments

Hello.
Quick question: Where would you put shared react-query wrappers? Say one were to have a modal dialog that is used by multiple features (and therefore lives in /components) and that is responsible for loading something from a server endpoint...
Cheers

I would put it under /hooks of the specific feature.

@ChambreNoire

Like @Odas0R said, the /hooks directory would work.

I put them in a /api directory to separate api specific hooks from other hooks. Also its adds a bit of consistency, so any react-query wrappers are found in the /api directory regardless of whether its in a feature or not.

Yeah, I agree, @CodeNameGrant. I guess I may have misunderstood the question since I've been doing exactly how you said for a couple of months 😆.