SlideShare a Scribd company logo
Fundamentals of Web Design
• Web design refers to the design of websites
that are displayed on the internet.
• It usually refers to the user experience aspects
of website development rather than software
development.
Web Page & Web Site
Webpage Website
Webpage consists of content
regarding a single entity type
Website constitutes content
regarding several entities
A direct URL link or a website can
be used to access it
A domain address is used to access
it
A combination of webpages is
created using HTML and CSS
Information is in HTML language
An individual hypertext document
linked under a website
A collection of multiple pages
hosted on the server
Stores the contents or resources
that are to be displayed on a
website
Is a place used to display the
content
Webpage Website
Comparatively, less complex More complex to develop
Less time to develop Takes more time to develop
The web page address of any
specific website is directly
dependent on the website address
(domain). Webpage will not work
if the domain is down
Website address (domain) is
independent of webpage address.
If the webpage is deleted for any
reason, the website will still
continue to work. All other linked
webpages will also work as usual
Examples: Contact page,
Registration Page, Service Page,
About Us page and so on
Examples: Flipkart.com,
Nykaa.com, Amazon.com and
more
Web Application
• A Web application (Web app) is an application
program that is stored on a remote server
and delivered over the Internet through a
browser interface.
• Web services are Web apps by definition and
many, although not all, websites contain Web
apps.
Full Stack_Reac web Development and Application
Web Application Website
Web application is designed
for interaction with end users.
Website basically contains
static content.
The user of web application
can read the content of web
application and also
manipulate the data.
The user of website only can
read the content of website
but not manipulate .
The web application site
should be precompiled before
deployment.
The website does not need to
be precompiled .
The function of a web
application is quite complex.
The function of website is
simple.
Web Application Web Site
Web application is interactive
for users.
Web site is not interactive for
users.
The browser capabilities
involved with a web application
is high.
The browser capabilities
involved with web site is high.
Integration is complex for web
application because of its
complex functionality.
Integration is simpler for web
site.
Web application mostly requires
authentication
In web site authentication is not
necessary.
EXAMPLE :- Amazon, Facebook,
etc.
EXAMPLE :- Breaking News,
Aktu website, etc.
Client-Server Architecture
• A client server application uses a two-tier
architecture whereas a web application uses
multi-tier architecture which consists of; user
client, middle tier, and application server.
• A web application uses a single-user system
unlike a client server application which uses
two users: client and server.
Full Stack_Reac web Development and Application
React JS
• React is a JavaScript library for building user
interfaces.
• React is used to build single-page applications.
• React allows us to create reusable UI
components.
• React, sometimes referred to as a frontend
JavaScript framework, is a JavaScript library
created by Facebook.
• React is a tool for building UI components.
How does React Work?
• React creates a VIRTUAL DOM in memory.
• Instead of manipulating the browser's DOM
directly, React creates a virtual DOM in memory,
where it does all the necessary manipulating,
before making the changes in the browser DOM.
• React only changes what needs to be changed!
• React finds out what changes have been made,
and changes only what needs to be changed.
React.JS History
• Current version of React.JS is V18.0.0 (April 2022).
• Initial Release to the Public (V0.3.0) was in July 2013.
• React.JS was first used in 2011 for Facebook's
Newsfeed feature.
• Facebook Software Engineer, Jordan Walke, created
it.
• Current version of create-react-app is v5.0.1 (April
2022).
• create-react-app includes built tools such as
webpack, Babel, and ESLint.
React Getting Started
• To use React in production, you need npm
which is included with Node.js.
• To get an overview of what React is, you can
write React code directly in HTML.
• But in order to use React in production, you
need npm and Node.js installed.
Setting up a React Environment
• If you have npx and Node.js installed, you can
create a React application by using create-react-
app.
• If you've previously installed create-react-
app globally, it is recommended that you
uninstall the package to ensure npx always uses
the latest version of create-react-app.
• To uninstall, run this command: npm uninstall -g
create-react-app.
• Run this command to create a React
application named my-react-app:
– npx create-react-app my-react-app
Run the React Application
• Now you are ready to run your first real React
application!
• Run this command to move to the my-react-
app directory:
– cd my-react-app
• Run this command to run the React
application my-react-app:
– npm start
• A new browser window will pop up with your
newly created React App! If not, open your
browser and type localhost:3000 in the
address bar.
Render HTML
• React's goal is in many ways to render HTML in a web page.
• React renders HTML to the web page by using a function
called ReactDOM.render().
• The ReactDOM.render() function takes two arguments, HTML
code and an HTML element.
• The purpose of the function is to display the specified HTML
code inside the specified HTML element.
• But render where?
• There is another folder in the root directory of your React
project, named "public". In this folder, there is
an index.html file.
• You'll notice a single <div> in the body of this file. This is
where our React application will be rendered.
import React from 'react';
import ReactDOM from 'react-dom/client';
ReactDOM.render(<p>Hello</p>,
document.getElementById('root'));
import React from 'react';
import ReactDOM from
'react-dom/client';
const myelement = (
<table>
<tr>
<th>Name</th>
</tr>
<tr>
<td>John</td>
</tr>
<tr>
<td>Elsa</td>
</tr>
</table>
);
ReactDOM.render(myele
ment,
document.getElement
ById('root'));
React JSX
What is JSX?
– JSX stands for JavaScript XML.
– JSX allows us to write HTML in React.
– JSX makes it easier to write and add HTML in React.
Coding JSX
• JSX allows us to write HTML elements in JavaScript and
place them in the DOM without any createElement()
and/or appendChild() methods.
• JSX converts HTML tags into react elements.
• You are not required to use JSX, but JSX makes it easier
to write React applications.
import React from 'react';
import ReactDOM from 'react-dom/client';
const myElement = <h1>I Love JSX!</h1>;
const root =
ReactDOM.createRoot(document.getElementB
yId('root'));
root.render(myElement);
import React from 'react';
import ReactDOM from 'react-dom/client';
const myElement = <h1>React is {5 + 5} times
better with JSX</h1>;
const root =
ReactDOM.createRoot(document.getElement
ById('root'));
root.render(myElement);
import React from 'react';
import ReactDOM from 'react-dom/client';
const myElement = (
<ul>
<li>Apples</li>
<li>Bananas</li>
<li>Cherries</li>
</ul>
);
const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(myElement);
React Components
• Components are like functions that return HTML
elements.
• React Components
• Components are independent and reusable bits of
code. They serve the same purpose as JavaScript
functions, but work in isolation and return HTML.
• Components come in two types, Class components
and Function components, in this tutorial we will
concentrate on Function components.
Create Your First Component
• When creating a React component, the component's
name MUST start with an upper case letter.
• Class Component
• A class component must include the extends
React.Component statement. This statement creates
an inheritance to React.Component, and gives your
component access to React.Component's functions.
• The component also requires a render() method, this
method returns HTML.
import React from 'react';
import ReactDOM from 'react-dom/client';
function Car() {
return <h2>Hi, I am a Car!</h2>;
}
const root =
ReactDOM.createRoot(document.getElementByI
d('root'));
root.render(<Car />);
Components in Components
function Car() {
return <h2>I am a Car!</h2>;
}
function Garage() {
return ( <>
<h1>Who lives in my Garage?</h1>
<Car />
</> );
}
const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);
Components in Files
• This is the new file, we named it "Car.js":
function Car() {
return <h2>Hi, I am a Car!</h2>;
} export default Car;
• Now we import the "Car.js" file in the application, and we
can use the Car component as if it was created here.
import React from 'react';
import ReactDOM from 'react-dom/client';
import Car from './Car.js';
const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(<Car />);
React Props
• Props are arguments passed into React
components.
• Props are passed to components via HTML
attributes.
• props stands for properties.
React Props
• React Props are like function arguments in
JavaScript and attributes in HTML.
• To send props into a component, use the same
syntax as HTML attributes
import React from 'react';
import ReactDOM from 'react-dom/client';
function Car(props) {
return <h2>I am a { props.brand }!</h2>;
}
const myElement = <Car brand="Ford" />;
const root =
ReactDOM.createRoot(document.getElementB
yId('root'));
root.render(myElement);
function Car(props) {
return <h2>I am a { props.brand }!</h2>;
}
function Garage() {
return ( <> <h1>Who lives in my garage?</h1>
<Car brand="Ford" /> </> );
}
const root =
ReactDOM.createRoot(document.getElementByI
d('root'));
root.render(<Garage />);
React Events
• Just like HTML DOM events, React can perform actions
based on user events.
• React has the same events as HTML: click, change,
mouseover etc.
Adding Events
– React events are written in camelCase syntax:
– onClick instead of onclick.
– React event handlers are written inside curly braces:
– onClick={shoot} instead of onClick="shoot()".
• React:
– <button onClick={shoot}>Take the Shot!</button>
• HTML:
– <button onclick="shoot()">Take the Shot!</button>
function Football() {
const shoot = () => {
alert("Great Shot!");
}
return (
<button onClick={shoot}>Take the shot!</button>
);
}
const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(<Football />);
function Football() {
const shoot = (a) => {
alert(a);
}
return (
<button onClick={() => shoot("Goal!")}>Take the
shot!</button>
);
} const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(<Football />);
Conditional Rendering
if Statement
function Goal(props) {
const isGoal = props.isGoal;
if (isGoal) {
return <MadeGoal/>;
}
return <MissedGoal/>;
}
const root =
ReactDOM.createRoot(document.getElementById('r
oot'));
root.render(<Goal isGoal={false} />);
React Lists
function Car(props) {
return <li>I am a { props.brand }</li>;
}
function Garage() {
const cars = ['Ford', 'BMW', 'Audi'];
return ( <> <h1>Who lives in my garage?</h1>
<ul>
{cars.map((car) => <Car brand={car} />)}
</ul>
</> );
}
const root =
ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);
function Car(props) {
return <li>I am a { props.brand }</li>;
}
function Garage() {
const cars = [
{id: 1, brand: 'Ford'},
{id: 2, brand: 'BMW'},
{id: 3, brand: 'Audi'} ];
return (
<> <h1>Who lives in my garage?</h1>
<ul>
{cars.map((car) => <Car key={car.id} brand={car.brand} />)} </ul> </> );
}
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Garage />);
Thinking with React…

More Related Content

Similar to Full Stack_Reac web Development and Application (20)

PPTX
React_Complete.pptx
kamalakantas
 
PDF
Learn react by Etietop Demas
Etietop Demas
 
PPTX
INTRODUCTION TO REACT JAVASCRIPT FOR BEGINNERS.pptx
JamesGedza1
 
PPTX
Introduction to React Language (1).pptx
AleksandrosHodo
 
PPTX
NEXTjs.pptxfggfgfdgfgfdgfdgfdgfdgfdgfdgfg
zmulani8
 
PPTX
ReactJS.pptx
SamyakShetty2
 
PDF
React in Action ( PDFDrive ).pdf
almako2
 
PDF
Fundamental concepts of react js
StephieJohn
 
PPTX
React101 v3
Janice Gluck
 
PDF
Learning React js Learn React JS From Scratch with Hands On Projects 2nd Edit...
bandmvh3697
 
PPTX
Reactjs
Mallikarjuna G D
 
PDF
Front-End Developer's Career Roadmap
WebStackAcademy
 
PDF
Intro to react_v2
Feather Knee
 
PDF
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Stack Learner
 
PDF
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
PDF
The complete-beginners-guide-to-react dyrr
AfreenK
 
PDF
0900 learning-react
RohitYadav696
 
PDF
react.pdf
yihunie2
 
PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 
React_Complete.pptx
kamalakantas
 
Learn react by Etietop Demas
Etietop Demas
 
INTRODUCTION TO REACT JAVASCRIPT FOR BEGINNERS.pptx
JamesGedza1
 
Introduction to React Language (1).pptx
AleksandrosHodo
 
NEXTjs.pptxfggfgfdgfgfdgfdgfdgfdgfdgfdgfg
zmulani8
 
ReactJS.pptx
SamyakShetty2
 
React in Action ( PDFDrive ).pdf
almako2
 
Fundamental concepts of react js
StephieJohn
 
React101 v3
Janice Gluck
 
Learning React js Learn React JS From Scratch with Hands On Projects 2nd Edit...
bandmvh3697
 
Front-End Developer's Career Roadmap
WebStackAcademy
 
Intro to react_v2
Feather Knee
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Stack Learner
 
FRONTEND DEVELOPMENT WITH REACT.JS
IRJET Journal
 
The complete-beginners-guide-to-react dyrr
AfreenK
 
0900 learning-react
RohitYadav696
 
react.pdf
yihunie2
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
Karmanjay Verma
 

More from Jeyarajs7 (15)

PPTX
Python Using Face Detection Coding Session
Jeyarajs7
 
PPTX
Python Using Face Detection Coding Session
Jeyarajs7
 
PPTX
Full Stack_HTML- Hypertext Markup Language
Jeyarajs7
 
PPTX
AI PPT 2023 for College Students and Arts
Jeyarajs7
 
PPTX
AI PPT 2023 for College Students and Arts
Jeyarajs7
 
PPTX
Technology Readiness Level in Computer Sci
Jeyarajs7
 
PPTX
Technology Readiness Level in Computer Sci
Jeyarajs7
 
PPTX
DIGITAL MARKETING UPDATE VERSION NEW ONE
Jeyarajs7
 
PPTX
IT Related file Hardware and Software SPec
Jeyarajs7
 
PPTX
Cream & Pastel Palette Healthcare Center Characters By Slidesgos.pptx
Jeyarajs7
 
PPTX
Math Subject for Elementary - 5th Grade_ Fractions I _ by Slidesgo.pptx
Jeyarajs7
 
PPTX
About Mental Health - Mrs.Sivakakthi.pptx
Jeyarajs7
 
PPTX
Machine Coding , Machine Language and AI
Jeyarajs7
 
PPTX
Basics of Fullstack like Web Development
Jeyarajs7
 
PPTX
C Programming with oops Concept and Pointer
Jeyarajs7
 
Python Using Face Detection Coding Session
Jeyarajs7
 
Python Using Face Detection Coding Session
Jeyarajs7
 
Full Stack_HTML- Hypertext Markup Language
Jeyarajs7
 
AI PPT 2023 for College Students and Arts
Jeyarajs7
 
AI PPT 2023 for College Students and Arts
Jeyarajs7
 
Technology Readiness Level in Computer Sci
Jeyarajs7
 
Technology Readiness Level in Computer Sci
Jeyarajs7
 
DIGITAL MARKETING UPDATE VERSION NEW ONE
Jeyarajs7
 
IT Related file Hardware and Software SPec
Jeyarajs7
 
Cream & Pastel Palette Healthcare Center Characters By Slidesgos.pptx
Jeyarajs7
 
Math Subject for Elementary - 5th Grade_ Fractions I _ by Slidesgo.pptx
Jeyarajs7
 
About Mental Health - Mrs.Sivakakthi.pptx
Jeyarajs7
 
Machine Coding , Machine Language and AI
Jeyarajs7
 
Basics of Fullstack like Web Development
Jeyarajs7
 
C Programming with oops Concept and Pointer
Jeyarajs7
 
Ad

Recently uploaded (20)

PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
PPTX
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
PPTX
national medicinal plants board mpharm.pptx
SHAHEEN SHABBIR
 
PDF
Right to Information.pdf by Sapna Maurya XI D
Directorate of Education Delhi
 
PPTX
VOMITINGS - NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
ARAL-Guidelines-Learning-Resources_v3.pdf.pptx
canetevenus07
 
PPTX
Orientation MOOCs on SWAYAM for Teachers
moocs1
 
PDF
water conservation .pdf by Nandni Kumari XI C
Directorate of Education Delhi
 
PPTX
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PDF
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
PPTX
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
PPTX
ENGLISH LEARNING ACTIVITY SHE W5Q1.pptxY
CHERIEANNAPRILSULIT1
 
PPTX
Auditing and Assurance Meaning - Objectives - Types - Advantages & Disadvanta...
DevaRam6
 
PDF
Module 1: Determinants of Health [Tutorial Slides]
JonathanHallett4
 
PPTX
FAMILY HEALTH NURSING CARE - UNIT 5 - CHN 1 - GNM 1ST YEAR.pptx
Priyanshu Anand
 
PDF
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
PPTX
How to Consolidate Subscription Billing in Odoo 18 Sales
Celine George
 
PPTX
Folding Off Hours in Gantt View in Odoo 18.2
Celine George
 
PPTX
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
national medicinal plants board mpharm.pptx
SHAHEEN SHABBIR
 
Right to Information.pdf by Sapna Maurya XI D
Directorate of Education Delhi
 
VOMITINGS - NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
ARAL-Guidelines-Learning-Resources_v3.pdf.pptx
canetevenus07
 
Orientation MOOCs on SWAYAM for Teachers
moocs1
 
water conservation .pdf by Nandni Kumari XI C
Directorate of Education Delhi
 
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
SCHOOL-BASED SEXUAL HARASSMENT PREVENTION AND RESPONSE WORKSHOP
komlalokoe
 
ENGLISH LEARNING ACTIVITY SHE W5Q1.pptxY
CHERIEANNAPRILSULIT1
 
Auditing and Assurance Meaning - Objectives - Types - Advantages & Disadvanta...
DevaRam6
 
Module 1: Determinants of Health [Tutorial Slides]
JonathanHallett4
 
FAMILY HEALTH NURSING CARE - UNIT 5 - CHN 1 - GNM 1ST YEAR.pptx
Priyanshu Anand
 
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
How to Consolidate Subscription Billing in Odoo 18 Sales
Celine George
 
Folding Off Hours in Gantt View in Odoo 18.2
Celine George
 
DIARRHOEA & DEHYDRATION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
Ad

Full Stack_Reac web Development and Application

  • 1. Fundamentals of Web Design • Web design refers to the design of websites that are displayed on the internet. • It usually refers to the user experience aspects of website development rather than software development.
  • 2. Web Page & Web Site Webpage Website Webpage consists of content regarding a single entity type Website constitutes content regarding several entities A direct URL link or a website can be used to access it A domain address is used to access it A combination of webpages is created using HTML and CSS Information is in HTML language An individual hypertext document linked under a website A collection of multiple pages hosted on the server Stores the contents or resources that are to be displayed on a website Is a place used to display the content
  • 3. Webpage Website Comparatively, less complex More complex to develop Less time to develop Takes more time to develop The web page address of any specific website is directly dependent on the website address (domain). Webpage will not work if the domain is down Website address (domain) is independent of webpage address. If the webpage is deleted for any reason, the website will still continue to work. All other linked webpages will also work as usual Examples: Contact page, Registration Page, Service Page, About Us page and so on Examples: Flipkart.com, Nykaa.com, Amazon.com and more
  • 4. Web Application • A Web application (Web app) is an application program that is stored on a remote server and delivered over the Internet through a browser interface. • Web services are Web apps by definition and many, although not all, websites contain Web apps.
  • 6. Web Application Website Web application is designed for interaction with end users. Website basically contains static content. The user of web application can read the content of web application and also manipulate the data. The user of website only can read the content of website but not manipulate . The web application site should be precompiled before deployment. The website does not need to be precompiled . The function of a web application is quite complex. The function of website is simple.
  • 7. Web Application Web Site Web application is interactive for users. Web site is not interactive for users. The browser capabilities involved with a web application is high. The browser capabilities involved with web site is high. Integration is complex for web application because of its complex functionality. Integration is simpler for web site. Web application mostly requires authentication In web site authentication is not necessary. EXAMPLE :- Amazon, Facebook, etc. EXAMPLE :- Breaking News, Aktu website, etc.
  • 8. Client-Server Architecture • A client server application uses a two-tier architecture whereas a web application uses multi-tier architecture which consists of; user client, middle tier, and application server. • A web application uses a single-user system unlike a client server application which uses two users: client and server.
  • 11. • React is a JavaScript library for building user interfaces. • React is used to build single-page applications. • React allows us to create reusable UI components. • React, sometimes referred to as a frontend JavaScript framework, is a JavaScript library created by Facebook. • React is a tool for building UI components.
  • 12. How does React Work? • React creates a VIRTUAL DOM in memory. • Instead of manipulating the browser's DOM directly, React creates a virtual DOM in memory, where it does all the necessary manipulating, before making the changes in the browser DOM. • React only changes what needs to be changed! • React finds out what changes have been made, and changes only what needs to be changed.
  • 13. React.JS History • Current version of React.JS is V18.0.0 (April 2022). • Initial Release to the Public (V0.3.0) was in July 2013. • React.JS was first used in 2011 for Facebook's Newsfeed feature. • Facebook Software Engineer, Jordan Walke, created it. • Current version of create-react-app is v5.0.1 (April 2022). • create-react-app includes built tools such as webpack, Babel, and ESLint.
  • 14. React Getting Started • To use React in production, you need npm which is included with Node.js. • To get an overview of what React is, you can write React code directly in HTML. • But in order to use React in production, you need npm and Node.js installed.
  • 15. Setting up a React Environment • If you have npx and Node.js installed, you can create a React application by using create-react- app. • If you've previously installed create-react- app globally, it is recommended that you uninstall the package to ensure npx always uses the latest version of create-react-app. • To uninstall, run this command: npm uninstall -g create-react-app.
  • 16. • Run this command to create a React application named my-react-app: – npx create-react-app my-react-app
  • 17. Run the React Application • Now you are ready to run your first real React application! • Run this command to move to the my-react- app directory: – cd my-react-app
  • 18. • Run this command to run the React application my-react-app: – npm start • A new browser window will pop up with your newly created React App! If not, open your browser and type localhost:3000 in the address bar.
  • 20. • React's goal is in many ways to render HTML in a web page. • React renders HTML to the web page by using a function called ReactDOM.render(). • The ReactDOM.render() function takes two arguments, HTML code and an HTML element. • The purpose of the function is to display the specified HTML code inside the specified HTML element. • But render where? • There is another folder in the root directory of your React project, named "public". In this folder, there is an index.html file. • You'll notice a single <div> in the body of this file. This is where our React application will be rendered.
  • 21. import React from 'react'; import ReactDOM from 'react-dom/client'; ReactDOM.render(<p>Hello</p>, document.getElementById('root'));
  • 22. import React from 'react'; import ReactDOM from 'react-dom/client'; const myelement = ( <table> <tr> <th>Name</th> </tr> <tr> <td>John</td> </tr> <tr> <td>Elsa</td> </tr> </table> ); ReactDOM.render(myele ment, document.getElement ById('root'));
  • 24. What is JSX? – JSX stands for JavaScript XML. – JSX allows us to write HTML in React. – JSX makes it easier to write and add HTML in React. Coding JSX • JSX allows us to write HTML elements in JavaScript and place them in the DOM without any createElement() and/or appendChild() methods. • JSX converts HTML tags into react elements. • You are not required to use JSX, but JSX makes it easier to write React applications.
  • 25. import React from 'react'; import ReactDOM from 'react-dom/client'; const myElement = <h1>I Love JSX!</h1>; const root = ReactDOM.createRoot(document.getElementB yId('root')); root.render(myElement);
  • 26. import React from 'react'; import ReactDOM from 'react-dom/client'; const myElement = <h1>React is {5 + 5} times better with JSX</h1>; const root = ReactDOM.createRoot(document.getElement ById('root')); root.render(myElement);
  • 27. import React from 'react'; import ReactDOM from 'react-dom/client'; const myElement = ( <ul> <li>Apples</li> <li>Bananas</li> <li>Cherries</li> </ul> ); const root = ReactDOM.createRoot(document.getElementById('root')); root.render(myElement);
  • 29. • Components are like functions that return HTML elements. • React Components • Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and return HTML. • Components come in two types, Class components and Function components, in this tutorial we will concentrate on Function components.
  • 30. Create Your First Component • When creating a React component, the component's name MUST start with an upper case letter. • Class Component • A class component must include the extends React.Component statement. This statement creates an inheritance to React.Component, and gives your component access to React.Component's functions. • The component also requires a render() method, this method returns HTML.
  • 31. import React from 'react'; import ReactDOM from 'react-dom/client'; function Car() { return <h2>Hi, I am a Car!</h2>; } const root = ReactDOM.createRoot(document.getElementByI d('root')); root.render(<Car />);
  • 32. Components in Components function Car() { return <h2>I am a Car!</h2>; } function Garage() { return ( <> <h1>Who lives in my Garage?</h1> <Car /> </> ); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Garage />);
  • 33. Components in Files • This is the new file, we named it "Car.js": function Car() { return <h2>Hi, I am a Car!</h2>; } export default Car; • Now we import the "Car.js" file in the application, and we can use the Car component as if it was created here. import React from 'react'; import ReactDOM from 'react-dom/client'; import Car from './Car.js'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Car />);
  • 35. • Props are arguments passed into React components. • Props are passed to components via HTML attributes. • props stands for properties. React Props • React Props are like function arguments in JavaScript and attributes in HTML. • To send props into a component, use the same syntax as HTML attributes
  • 36. import React from 'react'; import ReactDOM from 'react-dom/client'; function Car(props) { return <h2>I am a { props.brand }!</h2>; } const myElement = <Car brand="Ford" />; const root = ReactDOM.createRoot(document.getElementB yId('root')); root.render(myElement);
  • 37. function Car(props) { return <h2>I am a { props.brand }!</h2>; } function Garage() { return ( <> <h1>Who lives in my garage?</h1> <Car brand="Ford" /> </> ); } const root = ReactDOM.createRoot(document.getElementByI d('root')); root.render(<Garage />);
  • 39. • Just like HTML DOM events, React can perform actions based on user events. • React has the same events as HTML: click, change, mouseover etc. Adding Events – React events are written in camelCase syntax: – onClick instead of onclick. – React event handlers are written inside curly braces: – onClick={shoot} instead of onClick="shoot()". • React: – <button onClick={shoot}>Take the Shot!</button> • HTML: – <button onclick="shoot()">Take the Shot!</button>
  • 40. function Football() { const shoot = () => { alert("Great Shot!"); } return ( <button onClick={shoot}>Take the shot!</button> ); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Football />);
  • 41. function Football() { const shoot = (a) => { alert(a); } return ( <button onClick={() => shoot("Goal!")}>Take the shot!</button> ); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Football />);
  • 43. if Statement function Goal(props) { const isGoal = props.isGoal; if (isGoal) { return <MadeGoal/>; } return <MissedGoal/>; } const root = ReactDOM.createRoot(document.getElementById('r oot')); root.render(<Goal isGoal={false} />);
  • 45. function Car(props) { return <li>I am a { props.brand }</li>; } function Garage() { const cars = ['Ford', 'BMW', 'Audi']; return ( <> <h1>Who lives in my garage?</h1> <ul> {cars.map((car) => <Car brand={car} />)} </ul> </> ); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Garage />);
  • 46. function Car(props) { return <li>I am a { props.brand }</li>; } function Garage() { const cars = [ {id: 1, brand: 'Ford'}, {id: 2, brand: 'BMW'}, {id: 3, brand: 'Audi'} ]; return ( <> <h1>Who lives in my garage?</h1> <ul> {cars.map((car) => <Car key={car.id} brand={car.brand} />)} </ul> </> ); } const root = ReactDOM.createRoot(document.getElementById('root')); root.render(<Garage />);