'Is it recommended to pass setters from useState as props?
I am currently in a coding bootcamp and the instructor told me that it is not best practice to pass the setters defined in my useState as props to children components. Is this true? and if so, why?
Solution 1:[1]
First of all, it's ok to pass the setters down! Especially in small applications, it is very useful.
But In my experience when the app grows, it's better to use some kind of state management, like redux, recoil, context, and so on.
Also, in my opinion, in some cases will be very good to create a custom function like addUser
or something similar to prevent passing so many states down, maintaining more the logic on the parent component.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |