It became very popular because it has smaller API to learn(Components, States, Props, JSX) to get strated and is less complicated than other alternatives, it is backed by Facebook and also it’s perfect timing of release because Angular 2 was released at that time and it had backward incompatibility.
React can also be used in legacy applications and slowly replace them because setting it up and using it is just matter of putting few script tags in html file and starting to build components.
What is different about react from other front-end frameworks and libraries?
React is just a view layer of MVC. Other frameworks and libraries like Angular and Ember.js implement MVC.
What libraries you need to start using react in your projects?
First, you need to import react and react-dom libraries to get started with it. React DOM is required because react is independent of browser and can be used in mobile apps and VR devices. So if we want to build browser based app we use it as a wrapper.
If we need to use JSX then we need another library known as Babel that will transpile modern JS to plain old JS.
What is create-react-app?
It is tool built for getting started using react without much hassle of setting up. Using this command line tool we can easily create a new react project with no hassle of setting of webpack or so. It does most of the things for us.
What is npx?
It is an easy way to download and execute Node.js commands without installing them. For example we can use npx to create a new react project by
npx create-react-app myproject
This will download latest create-react-app, create a new project and finally remove it from our system.
Few important commands:
npm run build: To build the project in build folder when we are ready to deploy
npm eject: To change configurations added by
create-react-app. This will provide more flexibility in setting up babel and webpack. This action is irreversible.
npm test: To run test suite