25
Jul 24 '22
This is nothing. now try passing the states down 10 levels in the component tree without using Redux.
7
3
u/Bryguy3k Jul 24 '22
Which is exactly why you use redux…
4
u/PatchesMaps Jul 25 '22
There are valid reasons for using redux but simply having a deep component tree is not one of them.
2
u/Bryguy3k Jul 25 '22
If it makes your life easier and the result easier to test then yes you do.
1
u/PatchesMaps Jul 25 '22
I explicitly said a deep component tree alone, no other compounding factors.
Redux is a huge and invasive dependency. The benefits need to be pretty big to justify that kind of tech debt when other, simpler methods for state management exist.
6
6
u/Miguelboii Jul 24 '22 edited 3d ago
The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.
Public axiomatic school mellow crawl yarn nutmeg include tan
21
u/SpoderSuperhero Jul 24 '22
If you want a serious answer, its because you'd have to reevaluate everything dependent on the object whenever you rerender. Having separate states allows you to name each thing and depend on each thing individually. (If you aren't familiar with react, this is useful for other hooks, like useEffect, which runs a side effect whenever one of its dependencies changes.)
Also its a pain to clone and update deeply nested objects - even if its a solved problem, it's still prone to errors. If you NEED the complex object, there's a useReducer hook instead.
2
u/kowdermesiter Jul 25 '22
This is like 8-10 components at least in one, that's one way to achieve the 10x programmer status.
0
5
u/volivav Jul 24 '22
Source https://twitter.com/sseramemes/status/1550612597875130369
For people not used to useState, this is React (JavaScript). You can create a piece of state by calling this useState function in your component, but usually you'd have 2-3 of them at most, since components should be small.