Vuejs

React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It’s ‘V’ in MVC. ReactJS is an open-source, component-based front-end library responsible only for the view layer of the application. It is maintained by Facebook.
React uses a declarative paradigm that makes it easier to reason about your application and aims to be both efficient and flexible.

Reactjs

Features of React.js: There are unique features are available on React because that it is widely popular.

  • Use JSX: It is faster than normal JavaScript as it performs optimizations while translating to regular JavaScript. It makes it easier for us to create templates.
  • Virtual DOM: Virtual DOM exists which is like a lightweight copy of the actual DOM. So for every object that exists in the original DOM, there is an object for that in React Virtual DOM. It is exactly the same, but it does not have the power to directly change the layout of the document. Manipulating DOM is slow, but manipulating Virtual DOM is fast as nothing gets drawn on the screen.
  • One-way Data Binding: This feature gives you better control over your application.
  • Component: A Component is one of the core building blocks of React. In other words, we can say that every application you will develop in React will be made up of pieces called components. Components make the task of building UIs much easier. You can see a UI broken down into multiple individual pieces called components and work on them independently and merge them all in a parent component which will be your final UI.
  • Performance: React.js use JSX, which is faster compared to normal JavaScript and HTML. Virtual DOM is a less time taking procedure to update webpages content.

  1. Create a new React project
                    
                        npx create-react-app myapp
                    
                
  2. class based component
                                            import React, { Component } from 'react'                                      export class Contact extends Component {
                                            render() {
                                              return (
                                                
    Contact
    ) } } export default Contact
  3. fuction based component
                                             import React from 'react'                                      const Contact = () => {
                                            return (
                                              
    Contact
    ) } export default Contact
  4. start reactjs app
        
            npm start
    
    
  5. File structure in src folder (use cmd)
        
          mkdir Utils Assets Components Config Layouts Middleware Pages Routes Services Utils
    
    
  6. ADD blank many js files
        
          type NUL > sideBar.js 
          type NUL > Footer.js 
          type NUL > header.js
    
    
  7. for fetch id from link(route)
    useParams();

    According to the definition in React Router doc, useParams returns: an object of key/value pairs of URL parameters. Use it to access match.params of the current route

    • What does it mean in plain English?
    • It means whatever you set up in useParams(ex: title), your params have to match with the < Route path='/path/:title' > .

              
                import { useParams } from 'react-router-dom'
          
          
        
          const { id }=useParams();