React is a library and not a framework.
Here’s the React repo on GitHub if you want to check that out.
React is really helpful in creating User Interfaces (UIs) really easily. I try to compare it with Java and even Swift since I have worked in both for a while and if you’re a MVC kinda person then think of React as view in that structure.
Few advantages as per their official website
React automatically updates the view or the output of your code. So, even if you make a small change in your code, the whole view gets rewritten in seconds. Unlike programming languages like PHP or even simple HTML requires a refresh to update the view.
React makes the debugging easy — well at least a bit easier since the view gets updated constantly.
One of the biggest advantage is it divides the application in small components. Each component has its own state. Eventually, it compiles everything to make the complex app but for developers it’s easier to manage everything in smaller pieces.
By doing so React separates concerns with loosely coupled units called “components” that contain both.
In computer science, separation of concerns (SoC) is a design principle for separating a computer program into distinct sections such that each section addresses a separate concern.
All of those small code components are easily reusable which reduces the amount of code we write. Then it becomes a case of utilizing different components.
I a done with boring theory. Let’s build something.
Make sure you have node and npm installed on your computer. You’re going to need it to run the following commands.
If you’re in a rush, just run this command. I will go though everything in details later on.
npx create-react-app first-react-app // or use the following command npm init react-app first-react-app // if you're using yarn as a package manager than use this yarn create react-app first-react-app
If everything goes fine, just go inside the project by using this command:
Finally, start the app.
npm start // or yarn start
If you’re using Mac, it’ll ask for your permission for terminal app to open the app in Chrome. Approve it and you’ll see your app running in browser window just like this:
basics guide intro