DEV Community

Discussion on: Implementing State Management using Context API and Hooks in React

Collapse
 
marko911 profile image
Marko Bilal

Nothing to do with the content of the post but I did this in an attempt to avoid adding redux to a new app at work and then found myself having to implement things that were already done by react redux bindings. I wasted a lot of time trying to work around by just using context but ended up using redux anyways because it just made more sense.

I only see not using redux if your app really doesnt require much state management. I could be wrong but I spent 6-7 weeks doing this and couldn't justify not using redux.

Collapse
 
dance2die profile image
Sung M. Kim • Edited

Only yesterday, I finally gave in and replaced contexts with redux store.

To easy the pain, I used easy-peasy, which wraps Redux underneath the hood.

In my case, the migration was snappy as I was following Kent C. Dodd's Context Pattern mentioned in How to use React Context effectively, which exposes state & actions/dispatch separately via hooks, which is what Easy-Peasy does.

The upside was that, I was forced to "group" related states and actions together.

The reason my context approach was getting out of hand was, not because of any issues Context API (well, it does trigger re-render when it's updated everywhere) but because I was dumping all possible states without organizing them.