DEV Community

bagus prabangkoro
bagus prabangkoro

Posted on

My First Thought of React

Computer

Lately, I am continuing my online course on Udemy with an interesting topic: Modern React with Redux. This is my first time learning about this library, so I'm a bit curious about why this library is so famous. I am a Vue person, doing my work on the office mostly with Vue, and this React feels so strange to me. Strange but interesting at the same time. Here is my first thought of exploring React:

JSX!

If you have knowing Vue for a while, you might wonder how React put between template and logic. And here it comes JSX in-game. JSX combine template and logic. Nothing more, no place to separate them. It's a bit weird to me and changes my workflow as well.

Although it combines everything, it has benefit. Creating component in React is extremely simple! You can create one line of the method, and call it a component.

Functional Paradigm

React drives you to write short and reusable code. You rarely see any deep (Hadouken) code, especially in DOM element. React doesn't give you a syntactic sugar like v-for, v-if, v-else, like in Vue.

For example, every time you want to show repeated element. You have to utilize js syntax map.

A bit deep huh?

This situation has no syntactic sugar will drive you to write readable code, with no deep loop, no nested loop. A good practice is to separate this looping item into a single component.

Wonderful Props

I think this is the key value of React. It provides really powerful props. With props, you can pass anything, string, object, or even a Component! (passing component in props is not a good practice anyway, you can use props child instead) This is mind-blowing really.

Passing any data to props is really simple, and using it is simpler.

We don't need to define what props are passing, we just use it instantly.


React has pros and cons against Vue. It is limited on its syntactic sugar, but React has a simple rule so we can basically do anything with it. It gives us flexibility more than Vue.

Stay hungry, stay foolish

Top comments (0)