Re:When Does a Project Need React?
by z3t4 on Monday April 24, 2017 @03:11PM
(#14187125)
you should not store the state in the view layer. the easiest aproach is to store the state in the backend database layer.
[ Parent
| on HN ]
What about 'view state' such as which tokens have been typed into a typeahead/tagging style input? Or the expansion state of levels of a tree view? The active tab of a tabbed UI?
If nothing depends on the tagging, tree view or witch tab is active, then it's fine. Or if the state is discarded once the user click the "post" button it's also fine. But as features gets added things tend to "entangle" and things get more complicated. You'll end up with weird bugs like when the user has the app open in two tabs, or on two or more devices, where for example a message is marked as "read" on one devices but not the other. Or if two models interacts with the same view and races to change the state or just overwrites it.