Angular to React and Redux in 2018

//Angular to React and Redux in 2018

Angular to React and Redux in 2018

By | 2018-03-25T07:11:22+00:00 March 25th, 2018|

I have this love and hate relationship with Angular for quite some time now. It was funny because I was learning and in the middle of making a simple app when I got stuck. For weeks.

I noticed though that along the way in even making the simplest features work seems a struggle to the point that I’m not even sure if it’s worth using Angular at this point. I grasped the basic fundamentals thoroughly and that should be enough to make the small features work.

But, no it didn’t worked out. And what’s worse is it feels like I’m not even using javascript at all. It’s more like a different language altogether.

I love typescript, but somehow I got agitated in using it because I invested a lot of time mastering the ins and outs of plain javascript. And it really feels like I’m still doing some back-end stuffs (Dependency Injections, Services, etc.). What’s weird enough is everything feels familiar and equally frustrating.

Then one day, finally, I gave up using Angular and looking for other alternatives such as React and Vue. I tried React in the past around mid 2015 when it came out. I remembered it was still in beta and lots of people were talking about it. I didn’t understand the whole flow of it including the “state”.

But around 4th quarter of 2017 I tried to revisit it and watched courses related to React and Redux. I got curious what’s the fuss on the library that it became insanely popular around 2017, plus the hype on so-called immutability.

I love AngularJS (the first version of Angular) to the point that I loved the quirks of it and studied it a lot. But when I transferred over to Angular 2+ and made some initial investments of my time in it, I felt like something’s not right and for some reason it fails to deliver the most easiest features that’s possible in React.

Fast-forward: Finally I’m glad I did. It was actually so easy to deliver the basic features once you know the basic fundamentals of React.

I’ve been using React in my new projects for months now, and I can truly say I have no regrets in trying their ecosystem. Since then, I never leaned back in using Angular anymore.

So, if you might ask: Despite of my love with Angular in the past, what made me shift in React? And why is it not just about it’s flexibility?

A little bit of debate: Don’t compare Apples to Oranges

I meant no harm in both ecosystems, and probably let’s just say that it’s easier to integrate new features in React than Angular because React is a library and Angular is a FrameworkThere’s obviously a big difference between the two that most people overlooked.

When you’re using a library, it’s just one part of your application. So obviously the learning curve is small as well, and you can blend in some other libraries you might wanna use.

Framework, on the other hand is big. And you are to adhere with their standard way of doing things (such as doing http requests, component bindings, event bindings and so on). In short, you are constrained to do everything their way. In the case of Angular, you need to do things the “Angular” way. Everything! It doesn’t matter how tricky it is to bend in their way, you have to follow it since you’re using a framework.

This is unlike in the case with React where it’s only responsible for the View portion. Other than that, you’re on your own to discover what you might wanna use for doing http requests, and subscribing to key bindings. You might wanna use either Redux or Flux for data store and state management. You have freedom.

Without further ado, here are the reasons why I used React now:

It’s a library. And therefore you can attach any javascript library of your choice as add-ons

This is probably obvious as React is just another javascript library, not a framework. As explained earlier, in React, you can easily attach any libraries of your choice. It doesn’t care about your stacks in javascript for as long as you know what you’re doing. React’s philosophy revolves around the concept of “lego bricks”. This is one big advantage you can have in a library, or better yet one of the most powerful benefits you can have. We all know that technologies come and go. So why spend most of your time in one framework when you still need to learn a lot of them?

And that’s precisely the point why I switched over to React: to only use what I need to. I probably don’t need a full-blown framework because I won’t use most of the features of the framework either way. Thing is, no matter how over-engineered or well-architect your application is, you can’t still escape the reality that you will eventually introduce some bugs along the way. So knowing that, why over-engineer things?

Back then in Angular when I tried to create a feature that involves attaching a global event handlers, I was surprised how much work I have to do just to make it work!

I searched StackOverflow a couple of times and the answers were the same. You still have to go through a series of challenges just to make this work. By challenges I mean a lot of work actually. I solved the problem at the end of the day by using Event Emitters that broadcasts the events in multiple components and injecting them in every controllers. Whew! That’s a lot of work for something so simple.

I’m not saying it was poorly implemented. But probably I still need to invest a lot of time just to make a simple app work.

React does this effortlessly by using another js library called mousetrap to actually bind global keys in my entire application. Now I can use what I’ve learned in vanilla javascript.