Is it okay to build a React app without a state management library?

0
12
Asked By CuriousCactus83 On

I'm currently developing a React application and I've chosen not to use any global state management libraries like Redux, even though I do have some localized states for things like whether the sidebar is open or which tab is selected. I rely on Tanstack Query for handling data fetching and mutations, using it to manage states like the logged-in user. My approach involves refetching data when changes occur instead of using dedicated libraries for state management. I understand that server-side states are important, but I often see others using Redux, which I'm not a fan of. Does my method make sense, or should I rethink my approach? I know Tanstack Query could fit the role of a state management library in a way, but I'm referring to those others specifically designed for global management, like Redux or Zustand.

5 Answers

Answered By ChillPanda42 On

Honestly, you're already utilizing state management through Tanstack Query. It's capable of managing your app's state without the need for something like Redux. A lot of developers mix data layers within their components, which can lead to complexity, but your setup sounds pretty solid!

EasyTiger99 -

Exactly! Tanstack Query does a lot of the heavy lifting for state management.

Answered By ChillVibes88 On

You’re doing fine! Many modern apps are being built without heavy state management. Just make sure to think about it if you start encountering complex user interactions that need shared state across multiple components. For now, Tanstack Query paired with local state seems sufficient!

Answered By WittyDolphin74 On

Why do you dislike Redux so much? I find it often overcomplicates things that could be managed with local state or simpler solutions. It's usually overkill for most applications.

SkepticalOtter53 -

From my perspective, it's just adding unnecessary bloat since I've seen it used for trivial states like form states, making it a hassle.

PragmaticPineapple21 -

I get that! My experience has shown that it can introduce just too much boilerplate for simple states.

Answered By CodingNerd83 On

Using local state and queries can work quite well. You'll find some complex scenarios later where a global state might be needed, but until then, it seems like you're on the right track! Keep your components clean and focused with local state and let Tanstack Query handle the rest.

Answered By CoolCat1999 On

Your approach is valid! Using local component state along with server state via Tanstack Query is a great strategy. Most of what you consider global state is likely server state anyway, and Tanstack Query manages that effectively.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.