DEV Community

Discussion on: My thoughts on endless battle of React state management libraries (setState/useState vs Redux vs Mobx)

Collapse
 
adamashored profile image
adam-ashored

No - it does not let you easily share state in all components. It let's you easily share state in all components that are descendents of the context provider.

Personally, I love context. It allows me to think of controllers as components. I don't have to deal with the boilerplate of redux and I don't have to deal with the magic of mobx.

But, if I'm on a team of developers that have various levels of experience in react, I would almost always go for redux as long as an experienced senior is driving the redux bus. If everybody on the team is experienced seniors in react, then context is a-ok by me.

Collapse
 
rehubbard profile image
Eric Hubbard • Edited

Having to be a descendant of a context provider isn't a huge limitation or drawback for context. But I'm sure there are some scenarios I could be missing where that's an issue.

Thread Thread
 
adamashored profile image
adam-ashored

I didn't say, nor imply, it was a drawback. It's not. It's actually a huge feature. React is still, even after several years of composable UI, a "new way of doing things" to a lot of devs and it's hard (or impossible) to grok it all at the outset. To say something like "context lets you share state across all components" is a confusing statement to the ones who haven't made their own mental models yet when they try it and it fails, or they nest context providers without realizing it and end up in a really uncomfortable state because they can't connect "context = global shared state" with what they're seeing with they're own eyes.

Thread Thread
 
rehubbard profile image
Eric Hubbard

Ah I gotcha. I read your original comment wrong. Thanks for clearing that up for other readers 👍