DEV Community

Claiton Barreto
Claiton Barreto

Posted on

Structure for useReducer + Context Api

I've been studyng about Context API and useReducer hook, but i found nothing talking about pattern or file structure to use in projects with that.

I got to this structure:

image

Inside the context folder, i have the context itself and the reducer that controls the context state.

image

And in the component, i never (or almost never) access the context directly, leaving this job to a custom hook.

The complete code is here

What you think or comment about this ?

Top comments (0)