← back to the blog


React is easy. Why did I started with ReactJs?

Posted on September 30th, 2018 in JavaScript by George

 

ReactJs it is a JavaScript library that is used to build User Interfaces and does it using JSX. First time I seen JSX I have been skeptical and my first reaction was: "what is going on here?". XML like syntax, html embedded in JavaScript, such an eloquent way of coding UI.

The idea behind JSX it is that you can create UI components where html is complementing with JavaScript in an elegant way that is going to feel immediately natural. Therefore you end up having your markup and logic together. This is the main reason for which I started with React for single page applications.

But you are not limited to SPA. Using react router you can build dynamic websites and upgrading react state with Redux is going to show that you got some powerful tools under your control.

The most difficult part of react, where I had to dedicate more time to learn properly, are the life cycle methods of components. But again, soon as you understand what you doing, the knowledge of life cycle methods it is very empowering and rewarding.

Here is an example of how ingenious it is JSX and how logic can be implemented straight into the markup. This example it is taken directly from React documentation page. Go there in order to get a better understanding of the technical details.

function formatName(user) {
  return user.firstName + ' ' + user.lastName;
}

const user = {
  firstName: 'George',
  lastName: 'Crisan'
};

const element = (
  <h1>
Hello, {
formatName(user)} !
</h1> );