React: Front-End Framework
Why use React?
- Virtual DOM – A virtual DOM object is a representation of a DOM object. Virtual DOM is actually a copy of the original DOM. Any modification in the web application causes the entire UI to re-render the virtual DOM. Then the difference between the original DOM and this virtual DOM is compared and the changes are made accordingly to the original DOM.
- Components – ReactJS supports Components. Components are the building blocks of UI wherein each component has a logic and contributes to the overall UI. These components also promote code reusability and make the overall web application easier to understand.
- High Performance – Features like Virtual DOM, JSX and Components makes it much faster than the rest of the frameworks out there.
- You can start your react application by first installing “create-react-app” using npm or yarn.
npm install create-react-app --global
- After that you can create a new react app by using.
Then navigate into the “app_name” folder and type yarn start or npm start to start your application.
- A typical React application looks like this:
A small React Example:
- Update index.js file
ReactDOM.render( <h1>Hello DEVELOPERS!!</h1>, document.getElementById('root') );
- Use the below commands to run your application.