Hacker News new | past | comments | ask | show | jobs | submit login
React v16.13.0 (reactjs.org)
39 points by nnx 39 days ago | hide | past | web | favorite | 11 comments

Using react with hooks and typescript and wanted to report I'm happy with it.

The biggest changer to me was TypeScript and DefinitelyTyped covering pretty much every package I end up trying out.

Hooks save a layer of indentation, and in most components, I don't need all the class stuff. In addition I find it harder to manage renders in classes.

Some design decisions, like overextending use of redux-forms can be a pain to back out of. Maintaining typings for these thing break often in my experience. I'm trying to stay away from redux (the data store) in favor of managing stuff through relay mutations.

Nice little comforts like prettier (code formatter) go a long way.

And apparently tslint is being deprecated in favor of eslint (https://github.com/typescript-eslint/typescript-eslint).

Code splitting via React.lazy / dynamic imports working with minimal effort.

The other thing that has helped is webpack's API becoming more stable, editor extensions getting better. I'm getting consistent linting and completion in vim. Stuff is snapping together.

Another +1 for Hooks. I was really against it at first, but now I'll never go back. React components should really be nothing more than a view layer and Hooks forces you to stop thinking in the component/class paradigm, which generally makes things a lot more modular and reusable. I've been using XState to handle business logic and MobX as a data store, leaving React to simply render the data. No more huge class files and complicated life-cycle methods.

I agree with this as well. When hooks were released I thought it was a ridiculous generalization and abstraction over something that already worked. However, after using it in production for a while I can say I've seen the light and will not go back to component classes. After using hooks, you realize how bloated classes are, and how much logic gets crammed into componentDidUpdate in a weird bundle of mixed up concerns, all of which are now nicely clarified and flattened out with useEffect.

Another fascinating thing about useEffect is that it works in such a way that you easily realize common dependencies to reduce your code and improve performance overall.

Combine all this with TypeScript and building simple yet robust frontends is better than ever these days.

I feel like React hooks even though they provide a concise way to write code. they pushed react 2 decades back. classes had provided a standardized way to do stuff in React land. Now you're going to have places where people use hooks, others classes. n in my personal experience will result in different testing strategies n unknown bugs. this is one of the reasons, I quit working as frontend software engineer. just too much change

How do you push a 6 year old piece of software 2 decades back? I know you're exaggerating, but after admitting that you don't work with front end anymore (so I'm assuming you haven't really worked with hooks for very long) it's hard to understand why your opinion is of value here.

I've been working with React for 3+ years now and hooks are a major step forward in terms of both productivity and writing clean, efficient, reusable code. Anyone who spends some time wrapping their head around hooks realizes this and from what I see, a large majority of react / react-native library developers are on board as well.

Hooks can be adopted and implemented gradually along side class based components without issue, and no one has trouble when both exist along side each other. There is no rift in the react community because of this, and to suggest there is just reveals your ignorance, it's only pushing things forward.

it wasn't meant to be literal. '2 decades back' as a metaphor. hooks after all are just closures. so yeah I understand them. but that's not the problem. the issue is having two competing ways of doing things. look at rails they standardized the way of doing things way back and they haven't changed. & hence why a lot of rails people are productive

Best source for learning/grasping/getting-a-feel for hooks in your opinion ?

If you are into videos, I found this playlist to be helpful: https://www.youtube.com/playlist?list=PLC3y8-rFHvwisvxhZ135p...

He goes through how it used to be done before hooks and how easily it can be done now.

I've been through a few playlists with higher production value, but for me, this list just contained the right stuff.

I like the fact that you said "2 decades back" and then in the same breath you said "classes had provided a standardized way to do stuff in React land." Did you know that classes weren't the original way to do things in React land because JavaScript didn't have them? You'd use React's own version using React.createClass instead. For the longest time there were people against the introduction of classes in JavaScript because it obscured JavaScript's prototypal inheritance nature and they stuck to React.createClass and lamented that "class Foo extends React.Component" was too much divergence from React.createClass and made things inconsistent.

This reads more like reluctance to use the more functional paradigms react has to offer rather than anything being set back.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact