DEV Community

Discussion on: Rethinking Prop Drilling & State Management in React

 
bytebodger profile image
Adam Nathaniel Davis • Edited

Well, then I suppose I didn't make my argument persuasively enough. :-)

But to be honest, I don't expect to be able to persuade too many people. Especially not in a single post. And especially not those people who already use state management tools, are deeply ingrained in them, and, most likely, probably love them. Hell... I've been that guy (even if my go-to state management tool-of-choice is MobX).

This is only a realization that I've come to over several years. And I freely admit that many other React devs might never come to the same realization.

If my team were starting a new "green fields" project, I wouldn't really argue much at all with someone who says, "And we totally have to use MobX." I might suggest that we consider the Context API. Depending on the scope of the project, I might even oh-so-gently suggest that maybe we don't need a state management tool at all. But that's not a hill I'm gonna die on.

The only recommendation I'd actively argue against is Redux. But quite frankly, I have far bigger reasons for disliking Redux (which I assume I'll outline in some future post). And even then, my argument certainly would not be, "Let's ditch Redux and just use prop drilling!" My argument would me more like, "If we're adamant on using a state management tool, why wouldn't we at least consider MobX??" But more importantly, if shared state management is that important, why wouldn't we first consider React's native solution to the problem: the Context API???