ReactJs is a JavaScript library for building user interfaces. React focuses only on V (view) layer of MVC applications. Here are some features specific to react:
- JSX -
- A combination of both JavaScript and HTML used to render UI elements.
- Even though it's usage is not mandatory within react apps, it is recommended to use this as React considers building and rendering UI components an integral part of JS as we have event handlers, listeners e.t.c..
- JSX is just react friendly way of defining your HTML within JavaScript code as under the hood it uses regular JavaScript functions to render.
- Here is an example comparing JSX code and JavaScript code to create the same element:
- JSX:
- const heading = <h1 className="main-titles">Hello, React</h1>
- Without JSX:
const heading = React.createElement( 'h1', { className: 'main-titles' }, 'Hello, React' )
- Components:
- Components are one of the finest features and building blocks of react.
- These are used to build manageable, maintainable and re-usable pieces of code.
- Components let you split the UI code into multiple pieces and let you think about each piece in isolation this makes it really powerful library for large-scale applications.
- Unidirectional data flow:
- React follows one-way data flow policy.
- This means while designing an app you should always nest your child components within your parent components, these parent components will hold the data in an immutable variable called "state".
- The state is then passed from parent component to child components.
- Virtual DOM:
- Here's the official definition from documentation: The virtual DOM (VDOM) is a programming concept where an ideal, or “virtual”, representation of a UI is kept in memory and synced with the “real” DOM by a library such as ReactDOM. This process is called reconciliation.
- Virtual DOM eliminates the pain of manually targeting and updating the DOM elements to update UI, which makes it more developer friendly so whenever you made an update to component state React itself will take care of updating the DOM to match the new state.
- With Virtual DOM performance of the app gets improved as you're only updating the components whose state has been changed.
Resources:
Happy Coding ✌
Thanks for sharing this wonderful information. I too learn something new from your post..
ReplyDeleteReact JS Course in Chennai
React JS Training Institute in Chennai