Am I wrong for skipping state management libraries in my React app?

0
5
Asked By CuriousCoder87 On

I'm developing a React application without using any global state management libraries like Redux. Right now, I'm simply relying on local state for things like whether the sidebar is open or which tab is selected. I use Tanstack Query for fetching data and managing the logged-in user's state based on the query/cache results. Whenever I make changes, I just refetch the necessary queries. This strategy has worked for me, but I often hear others praising the use of libraries like Redux, and I can't help but feel like I'm missing something important. Should I reconsider my approach to state management in this context?

2 Answers

Answered By TechWhiz22 On

You're not crazy at all! Using Tanstack Query along with local component state is a perfectly valid approach for many applications. It's known as 'server state first,' and it works well because most global states, like user settings or info, are actually server states. Tanstack Query does a great job handling those aspects for you. Only look into global state management libraries like Redux if you start facing the need for complex shared state across disconnected components. Otherwise, keep it simple!

Answered By DevGuru99 On

Honestly, you're using state management already with Tanstack Query, so you're doing just fine. It's pretty common to manage local states for UI interactions while handling data fetching through a library like Tanstack. Redux really shines when you have complex scenarios like collaborative apps or when components need to read and write shared states frequently. If you don't face those issues, you don't need to complicate things!

ReactRookie -

I totally agree with that! Keeping data layers separate is often cleaner and avoids a lot of unnecessary bloat.

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.