3 ms·
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
by tony 7y ago
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 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.
- warent 7y agoI 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.
- aphextron 7y agoAnother +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.