Ask HN: How can we make React better?
21–30 of 68 posts
Re: Ask HN: How can we make React better?
#22So maybe you can pass forward refs from A to all the C's and then bypass B in the cases you want to directly trigger rerender on the individual affected C components. Is that the way to handle this scenario?
It's pretty late so the above maybe doesn't make sense, but to try to summarize, having a solution for updating deeply nested children without diffing all of the related components to see if they need rerender.
Re: Ask HN: How can we make React better?
#23Size. For my use case of a hybrid mobile app where I'd like to render lightweight webviews, the overhead of react is far too great. For this i'll actually reach for Preact instead. Or perhaps even the relatively new Svelte (disappearing) framework.
Thanks for the feedback! We've found that in most cases the components you've built tend to be much larger than React itself, and indeed if we can reduce the size of your components by adding things to React then that is often a good tradeoff for us. However we do try to keep the size down; for example React 16 included a 30% size reduction. When you say "the overhead of react is far too great" are you speaking from…
I'd love to see React itself ship with options to drop polyfills and old browser support if it helps the bundle size.
Re: Ask HN: How can we make React better?
#24Eliminate manual typing of PropTypes.
Re: Ask HN: How can we make React better?
#25Promote harmony, cross-compatibility, and longevity in the web development landscape.
Re: Ask HN: How can we make React better?
#26Re: Ask HN: How can we make React better?
#27Maybe this is either an uncommon use case or I'm missing an easy way to do it, but when you have a component tree like A->B->C (-> denoting child relation) and A contains most of the state and B contains many (say > 1k) children, and you keep updating state in A which only affects one or a few of C, the diffing process as I understand will check all of C whether they need to be rerendered. So if you update the state…
If that’s not fast enough, perhaps it would be faster to directly subscribe each instance of C to its state updates with something like Redux’ connect HOC. I assume that React does something like marking branches of the component tree as dirty and only doing a render pass on the dirty sections, but I could be wrong. If I’m correct, that would give you direct rerenders of the individual deeply nested C instances without rerendering A or B or unchanged C components at all.
Re: Ask HN: How can we make React better?
#28Re: Ask HN: How can we make React better?
#29Eliminate manual typing of PropTypes.
Just completed a chapter on PropTypes. While useful, they seem to be an excessive and tedious. Can't we somehow leverage TypeScript for the model validation instead?