React
React
npm : npm is the default package manager for the JavaScript runtime
environment Node.js
Check installation : Open your terminal and run these commands to verify the
installations
node –v
npm –v
What is React.js?
This promotes the reusability of code and thus faster work flow
Framework
Framework is an abstraction in which software providing generic functionality can be
selectively changed by additional user-written code, thus providing application-specific
software
• The Virtual DOM is a crucial concept utilized in modern frameworks such as React, which significantly
improves the performance of updating the real DOM.
• When a state change occurs in a React component, instead of updating the actual DOM directly, React
creates a lightweight replica of the DOM known as the Virtual DOM.
• React then compares the updated Virtual DOM with the previous one to identify the changes that need to
be applied to the real DOM.
• Once the changes are determined, React updates the real DOM in an optimized and efficient manner,
thereby reducing unnecessary re-renders and improving overall performance.
JSX
• JavaScript Syntax Extension — JSX is a syntax extension to
JavaScript.
• JSX allows HTML (XML) and JavaScript to be combined in one file
• With the help of JSX, we can write HTML code in the same file
that contains JavaScript code.
• JSX follows XML rules
• All elements must be placed inside one parent element
• All elements must be closed
JSX Syntax Rules
• Element tags
JSX Uses angle brackets (<>) to define elements, similar to HTML
• Components
Use components like (<header/>)
• Self closing tags
<img/> <input/>
• JavaScript Expressions
embed JavaScript expression within curly braces {}
JSX and HTML Differences
• class vs className
<div className=“my-class”></div>
• Inline styles
<div style ={{color:`color`}}></div>
• Navigate to the App and Move into your new app’s directory
cd my-first-app
• To Run in Browser
npm start
For Knowledge : Vite is a next-generation, front-end tool that focuses on speed and performance.
npm create vite@latest
npm run dev
Can browser read JSX Directly?
• Several tools exist for managing this process including Vite, babel
(Next generation compiler),Webpack and Snowpack
Components
Class Components
• Class components are the older way of defining components.
• Behavior through lifecycle methods
• Internal State management using this.state
• Can handle more complex logic
Why React ?
• Complex user interfaces • Performance
• SEO friendly • Powers of react native
• Strong community support • React increase productivity
• Code stability • React makes testing easy
• Fast rendering • Code reusability
• Virtual DOM • Create ecommerce application
• Apps using react js • Data binding
• Mobile app development • Ease of learning
• Flexibility • Easiest learning curve
• Has useful developer toolset • Easy debugging
• Independently deployable • Faster development
components • Improved developer productivity
• Improved SEO
References
• https://nodejs.org/en
• https://www.npmjs.com/
• https://react.dev/learn
• https://www.w3schools.com/REACT/DEFAULT.AS
• https://www.freecodecamp.org/news/the-difference-between-a-
framework-and-a-library-bd133054023f/
• https://code.visualstudio.com/
• https://www.youtube.com/watch?v=jwRAdGLUarw
• https://www.codecademy.com/learn/react-101
• https://vitejs.dev/guide/