bulletproof-react icon indicating copy to clipboard operation
bulletproof-react copied to clipboard

Shared/Common api location ?

Open ChambreNoire opened this issue 3 years ago • 5 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

ChambreNoire avatar May 11 '22 15:05 ChambreNoire

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

Odas0R avatar Aug 15 '22 19:08 Odas0R

@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.

CodeNameGrant avatar Sep 02 '22 06:09 CodeNameGrant

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 :laughing:.

Odas0R avatar Oct 26 '22 10:10 Odas0R