Can we use useState() at multiple time or is there any limit to use it in single component in React Js.
Asked
Active
Viewed 2,410 times
3
-
1You can call it as many times as you like, as long as you follow the [rules of hooks](https://reactjs.org/docs/hooks-rules.html) – Nicholas Tower Jul 11 '22 at 13:57
-
2If there's any kind of limit, it's going to be based on available resources and unrelated to the `useState` hook itself. More to the point, what happens when you *try*? Do you encounter any kind of problem? – David Jul 11 '22 at 13:59
1 Answers
3
You can use useState
multiple times. In fact it's even recommended in the React docs.
https://reactjs.org/docs/hooks-faq.html#should-i-use-one-or-many-state-variables
we recommend to split state into multiple state variables based on which values tend to change together.
I am not aware of any limit to its use.

Nice Books
- 1,675
- 2
- 17
- 21