React.js Introduction and Working
ReactJS uses a declarative paradigm which makes it possible for applications to be both effective and flexible. It creates simple views for each state in your application and efficiently updates and renders just the right component when your data changes. The declarative view makes your code more predictable and easier to debug. Each component in a React application is responsible for rendering a separate, reusable piece of HTML code. The ability to nest components within other components allows for the building of complex applications from simple building blocks. A component may also keep track of its internal state, for example, a TabList component may keep a variable for the open tab in memory.
Let us understand this with a practical example:
Let’s say one of your friends posted a photograph on Facebook. Now you go and like the image and then you started checking out the comments too. Now while you are browsing over comments you see that the likes count has increased by 100, since you liked the picture, even without reloading the page. This magical count change is because of ReactJS.
Note: React is not a framework. It is just a library developed by Facebook to solve some problems that we were facing earlier.
Now let’s install ReactJS in our system and see how it works and render the component.
Prerequisites: Download Node packages with their latest version.
Example: Create a new React project by using the command below.
npx create-react-app myapp
Filename App.js: Now change the App.js file with the given below code.
Although React was developed to be used in the browser, because of its design it can also be used in the server with Node.js.
Please Login to comment...