i am new to react-js and i saw some ways for react state management, such as redux hook and classbase component state
i was wondering which way is best way to do that,
in some languages i've seen that some statemangement has som bug or makes the app slower so i want to know which one is best way to do that in react,
thanks for your help and if you need more information please let me know

- 203
- 3
- 11

- 308
- 1
- 3
- 14
-
1Your question is opinion-based and such questions are off-topic on stackoverflow. Anyways, in my opinion, redux is a really good and popular option for state management in react apps. You might also want to look at mobx. – Yousaf Nov 27 '20 at 13:51
-
thank you ,do you know where i can ask this kind of questions? – thomas.s Nov 27 '20 at 13:54
-
Probably google, there are plenty of blogposts you can find. Describing the pros and cons of different libraries. – Kielstra Nov 27 '20 at 13:55
1 Answers
There are several popular libraries for state management in React, but one of the greatest things about React is that you don't need any extra libraries to get started. In fact, most people would recommend you stick to React and learn how it works before bringing in other libraries.
You mentioned class component state. You should know that whether you're using functional components with React hooks or class components, React state works the same.
Also, if you're interested in a library like Redux, which popularized the patterns using reducer functions and actions to make strict paths for updating state, you can use the useReducer
hook in React and mimic most of what Redux offers.
If you haven't already, you should check out the official docs on component state. The React documentation site is really good.
So, the "recommended" state management library really depends on what you're working on, but if you're new to React, then starting with useState
and useReducer
are going to be the best option. They will take you a long, long way.

- 521
- 2
- 5