by ferdowsi · 5y ago · 0 comments
Reading through the RFC is really interesting. They specifically call out the dependency on Facebook as effectively being React's Single Point of Failure, citing their negative experiences with HHVM.
And for all of the love that people give React's big shifts (like hooks), the RFC specifically counts this against them, given that best practices have shifted so drastically in the last few years.
Oh boy I was wrong.
Hooks are way more easier and intuitive than what I thought. It makes code so much more readable and easier to reason about. Especially when before you had to wrap your components into x number of HOCs to inject the props your component needed, risking props collision, making it really hard to debug and use with TypeScript, and eventually making it a nightmare to understand and maintain your component. I'm not surprised that every React library added a hook API to its core.
At the end of the day it makes me more productive, so I guess that big shift was also a big win.
That is a bit annoying, but it's significantly less annoying than having a single huge componentShouldUpdate function that deals with everything a complicated component uses.
Hooks don't really change the work a component does. The logic is essentially the same. They just break it down in to smaller, more reusable, more declarative units. That's usually nicer to work with and a lot more "React-y".
Microsoft forcing Windows on mobile devices in the 2000s is an easy example of that kind of failed leadership.
This subject matter is covered extensively in: https://en.wikipedia.org/wiki/The_Innovator%27s_Dilemma
Forget a dependency in the dependencies array, forget an useMemo or a useCallback and your application will rerender like crazy.
Yes, it looks nice from the point of view of understanding the code, but what actually happens at runtime and the amount of miss steps they can produce is astounding.
Nowadays I'm using Vue and it is way, way easier to deal with due to the reactivity model.
What kind of application are you developing? Do you have complex UI? Or just lots and lots of pages where you reuse components a lot?
You end up with code like this at the bottom of your files
myCustomHOC1(
myCustomHOC2(
withRouter(
reduxForm({ form: 'filters', initialValues, destroyOnUnmount: false })(
connect(mapStateToProps, mapActionsToProps)(MyComponent)
)
)
)
)
Although it's probably not that common anymore (as OC said, practices changed), it was a common pattern a few years ago.In the new project I started last week, I'm using only hooks/context and a few libraries like react-router (useHistory, useParams), react-query (useQuery, useMutation), react-hooks-form (useForm)… and it has been a breath of fresh air. react-query is definitely another "big shift", it completely changed the way I used to think about fetching data and centralize it. It's very good, I highly recommend to try it.
[1] https://medium.com/@dan_abramov/smart-and-dumb-components-7c...
And then just being the larger community, I just feel like all there's more examples in general for everything. Most things default to React as the guiding implementation.
Now, the original reason I chose Vue was mostly around a small client side package size, but all the SPA frameworks have some version that prides itself in small client side package side now, and they mostly reach parity on similar concepts.
But I can't imagine modern technology being where it is without big shifts. Perhaps that is not good for very long term projects. We'll see how Vue fairs in the long run if they never make any big shifts, I suppose.
Then again, none of the big shifts in React broke anything permanently, did they? I could be wrong about this, I haven't been paying attention since the very beginning…
Looks like you are remembering things differently. Facebook doubled down on public outcry and even react maintainers gave up on it.
Then wordpress chose to stop its adoption of react in its new editor. And that caused Facebook to change the licence.
The fact a big org was needed for this change, is a major factor for Facebook's distrust.
And now that the genie is out of the bottle anyone can do as they please with this fairly small rendering library and Facebook can't stop them. So I'm still not sure what the concern about Facebook is?
1. They chose to insert the clause and refused to use standard MIT license despite complaints from community and their own developers
2. They are the kind of company who chose to do shady stuff despite complaints from community and their own developers
#1 was fixed. #2 is still the case and may come to bite back in future. That is the concern
Vue 2 to Vue 3 has felt like a big shift. Big enough to leave most libraries incompatible with Vue3 and a lot of community forks spread around while library authors work out how (and if) to support both versions.
Vue 3 is an improvement to work with IMO but it's a rewrite your code kind of upgrade.