TypeScript, I Hardly Knew Ya
While it was difficult to get used to, I must admit that my time using TypeScript helped me write better code. Once I got the hang of it, and it helped me think through my code before I started writing it. This helped me catch my errors earlier in development, and I found working with others’ code easier because statically typed code is more clear. Here’s an article on the benefits (and some drawbacks) of static typed languages if you want to learn more.
Of course, React doesn’t require TypeScript. It’s possible, but most React developers don’t choose to use it. Most documentation, examples, and other resources are not in TypeScript. I’ve found myself enjoying the benefits of using a dynamically typed language again. While I don’t particularly miss TypeScript, I hope to continue the same level of consideration when writing my code that I learned when using the static typing superset. Also, React’s PropTypes encourage typing of the extra important stuff: Props that are passed to and from components.
The Many Roads of React
I was okay leaving TypeScript behind, but I was less pleased to find out that React did not have a React CLI like the Angular CLI. The Angular CLI is a time-saving tool that allows you to quickly create Angular 2 components, modules, directives, etc. with one little command. Run the command and Angular 2 would do all the dirty work of setting up the necessary imports and exports for you. You’d have a working component ready for you to build on.
React doesn’t have this. It’s much less prescriptive about how you build your application than Angular 2. This has many benefits, like being able to tailor it specifically to the application you’re building. It’s less great when learning how to use the library. Angular 2 was new when I used it, so there weren’t many community resources like blog posts or Stack Overflow questions and answers. However, the stuff that did exist was all very understandable because everyone used Angular 2 the same way. Everyone Reacts differently. I even found this within our own codebase where old best practices still existed in some code while newer, better ones were used elsewhere.
This was probably the hardest thing for me to wrap my head around, and I still struggle. Not because I don’t understand it, but because I’ve been writing CSS for so long it’s muscle memory, and remembering to write fontSize instead of font-size and put my properties in quotes was hard. It was like someone told me I suddenly had to start speaking a new dialect of English.
React is Easier to Learn
Despite the lack of prescriptive code structuring and weirdness of using JSX, I still had an easier time getting the hang of React than I did Angular 2. I think that’s because the whole concept of React is simpler than Angular 2. React also has a much stronger community: there are blog posts, videos, training material, and a plethora of Stack Overflow examples all over the Internet.
After developing in React for over two years now, I’ve come to appreciate some of the parts that I found difficult when initially learning. Even though I still try to write “normal” CSS sometimes, it’s nice not having to create a separate file just to hold a few styles. Not forcing engineers to build their applications in a specific way means we can be more flexible with our approach and create more robust products. Changing best practices means we can continue to evolve and improve our code.
But I still miss the Angular CLI.