3 ms·
I wonder how you avoid writing stateful components in real-world complex SPAs.
by buremba 8y ago
I wonder how you avoid writing stateful components in real-world complex SPAs.
- ilovecaching 8y agoIt's quite easy, I honestly think the only roadblock is how one thinks about computation. If you think of your UI as a single computational expression you're building up from functional composition, then the issue of state never arises. It's just about defining the shape of the interfaces.
- 33degrees 8y agoYou manage your state outside your components, using Redux / Relay / MobX etc...
- williamdclt 8y agoQuite easily. The state is held in Redux or whatever, the only state held by components are UI stuff (is this section collapsed? Is this date picker open?). In the last SPA I wrote there's about 100 components, less than 5 of them are stateful.
- The_suffocated 8y agoDiscussions of this sort are often confusing. When one talks about using Redux or some javascript library to do "state management", I always wonder whether one is talking about application states (i.e. states originating from business logic but unrelated to UI) or UI states.
- infinite8s 8y agoApplication states. Redux isn't meant to maintain UI state.