3 ms·
The whole React story is very interesting. Authors are extremely adamant about everything being pure, but React still doesn't solve an underlying issue that ev
by dham 6y ago
The whole React story is very interesting. Authors are extremely adamant about everything being pure, but React still doesn't solve an underlying issue that every frontend framework since the beginning of time solved. Which is automatic tracking of properties and re rendering efficiently(think Vue, Angular, Angular 2, Ember). IMO you need all these new optimization techniques crammed on top because it's so easy to shoot yourself in the foot with performance out of the box with React
Oh you didn't memoize a function, well you just re rendered a FlatList with 500 items in it on an Android phone that cost $0. You need an addon library such as Mobx to really unlock the power of React and make it sane enough to use.
- k__ 6y ago"Authors are extremely adamant about everything being pure" I had the excact opposite experience. Frameworks like Cycle.js and Callbags are pure and try to emphasize that, but React always priorized practical solutions higher than FP concepts.
- nightski 6y agoExcept you don't need an addon library at all. You can construct efficient and performant components using just react state/hooks and props.
- dham 6y agoYes, for sure you can get good performance out of the box. It just takes a lot more time than other frameworks. In my experience it's a constant moving state up and down. Spending an insane amount of time to put state in the correct spot so it will be efficient. The easiest thing is to just put all state/business logic in domain objects and subscribe the components to it. That's how you're used to thinking about business logic of an application anyway. It's easier to reason about and it performs much better. This whole useMemo, useCallback, is just comical. Let the computer do the work for you.
- nightski 6y agoWeird, never had any of those issues. I've always had state near the top and used props to bring it down. Pure components (which is any function component) do not re-render unless their props change. I've built rather complex applications also in the logistics and financial forecasting verticals. We are talking many tables, charts, dashboards, etc... In fact, I found the MobX approach with reactivity harder to control performance for because it's triggered by state changes. But when you trigger a lot of state updates it can be really hard to reason about performance because it's not obvious what components will update due to that change in state.
- dham 6y agoTables, Charts and Dashboards sounds like a lot of displaying of data. Not updating state. Or when you are updating state (like date picker), you're updating the world. Just an assumption, sorry if I'm wrong. Web is usually fine to be honest, doesn't come up until you're pushing state on keypress. The Stripe onboarding page and Twitter create tweet UI both have these performance problems. My day to day is React Native which is where these problems crop up almost immediately and getting performance out of the box is a chore that, again, none of the other frameworks make you do. Computers are smart they can solve these problems for us.