SlideShare ist ein Scribd-Unternehmen logo
1 von 12
ReactA JavaScript library for building user interfaces
NITIN TYAGI
Consulting Software Engineer
https://www.linkedin.com/in/nitin-tyagi-37832798/
React
Agenda
Session Introduction & Learning Philosophy
Why use React?
React Setup
JSX & Rendering Elements
React Parent/Child Components
React Functional Components and Class components
React Prop and State
React Lifecycle
Handling Events
React Native : Introduction
React
Session Introduction & Learning
Philosophy
What is React?
Trick is 3P….. Practice, Practice, Practice
Learn by doing examples. Scenario based problems.
Setup React environment and install new packages and play around.
Download react community projects and check out Architecture and
application.
https://reactjs.org/community/examples.html
Design your own project and Architecture.
Why use React?
• Virtual DOM.
HTML is easy to Manipulate. Unfortunately, easily doesn’t mean quickly here.
• Reusable Web Components.
• Maintained by Facebook
React Setup
• Download and install Visual studio code IDE. Free, Cross platform and Opensource
 https://code.visualstudio.com/download
• Download and install Node Js for JavaScript runtime.
 https://nodejs.org/en/
• Check npm latest is installed from above installation.
 https://www.npmjs.com/get-npm
• Create first React project by using below commands
 npm install -g create-react-app
 create-react-app my-app
 cd my-app
 npm start
 http://localhost:3000
React
JSX & Rendering Elements
• It is a syntax extension of JavaScript.
• JSX allows us to write HTML in React.
• For example consider below snippet.
• Let go back to visual studio code to see JSX in action.
const myelement = <h1>I Love
JSX!</h1>;
ReactDOM.render(myelement,
document.getElementById('root'));
const myelement =
React.createElement('h1', {}, 'I
do not use JSX!');
ReactDOM.render(myelement,
document.getElementById('root'));
Code Snippet : With JSX Code Snippet : Without JSX
React Parent/Child Components
ReactDOM.render( ,document.getElementById('root'));
<App/>
<WebPagebody /> <WebPagefooter /><WebPageheader />
<div>…..</div><header>..</header> <footer>...</footer>
React
React Functional Components and Class
components
• Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but
work in isolation and returns HTML via a render function.
• The simplest way to define a component is to write a JavaScript function:
function Welcome(props) { return <h1>Hello, {props.name}</h1>; }
You can also use an ES6 class to define a component:
class Welcome extends React.Component { render() { return <h1>Hello, {this.props.name}</h1>; }
}
• The above two components are equivalent from Reacts point of view.
• Lets go back to visual studio code and explore more.
React
React Prop and State
function Welcome(props) {
return <h1>Hello, {props.name}</h1>;
}
const element = <Welcome name=“Nitin" />; ReactDOM.render( element, document.getElementById('root') );
• Props are arguments passed into React components.
• Props are passed to components via HTML attributes.
• Props are also how you pass data from one component to another, as parameters.
Props are used to pass data from parent to child or by the component itself. They are immutable and thus will not be
changed. State is used for mutable data, or data that will change. This is particularly useful for user input.
• React components has a built-in state object.
• The state object is where you store property values that belongs to the component.
• When the state object changes, the component re-renders.
class Car extends React.Component {
constructor(props) { super(props); this.state = {Name: “Nitin"}; }
render() {
return ( <div> <h1>My Name</h1> </div> ); } }
React Lifecycle
• 3 major phases of React Lifecyle mounting, updating & unmounting
• Lets see some examples in action.
Mounting Updating Unmounting
 constructor()
 getDerivedStateFromPr
ops()
 render()
 componentDidMount()
 getDerivedStateFromPr
ops()
 shouldComponentUpd
ate()
 render()
 getSnapshotBeforeUpd
ate()
 componentDidUpdate(
)
 componentWillUnmou
nt()
Handling Events
Handling events with React elements is very similar to handling events on DOM elements. There are some syntactic
differences:
• React events are named using camelCase, rather than lowercase.
• With JSX you pass a function as the event handler, rather than a string.
button onClick={activateLasers}> Activate Lasers </button>
<
function ActionLink() { function handleClick(e)
{ e.preventDefault();
console.log('The link was clicked.’);
} return ( <a href="#" onClick={handleClick}> Click me </a> ); }
React
React Native : A framework for building Native Apps
Written in JavaScript—rendered with native code
React primitives render to native platform UI, meaning your
app uses the same native platform APIs other apps do.
Many platforms, one React. Create platform-specific versions
of components so a single codebase can share code across
platforms. With React Native, one team can maintain two
platforms and share a common technology—React.
For more React Native advantages. Visit below link.
https://www.oreilly.com/library/view/learning-react-
native/9781491929049/ch01.html

Weitere ähnliche Inhalte

Was ist angesagt?

React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorialMohammed Fazuluddin
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core ConceptsDivyang Bhambhani
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_jsMicroPyramid .
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation洪 鹏发
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsANKUSH CHAVAN
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITnamespaceit
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSKnoldus Inc.
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSXMicah Wood
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjsmanojbkalla
 
React web development
React web developmentReact web development
React web developmentRully Ramanda
 

Was ist angesagt? (20)

React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React workshop
React workshopReact workshop
React workshop
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
React-JS Component Life-cycle Methods
React-JS Component Life-cycle MethodsReact-JS Component Life-cycle Methods
React-JS Component Life-cycle Methods
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Introduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace ITIntroduction to React JS for beginners | Namespace IT
Introduction to React JS for beginners | Namespace IT
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
ReactJS
ReactJSReactJS
ReactJS
 
React-JS.pptx
React-JS.pptxReact-JS.pptx
React-JS.pptx
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSX
 
React and redux
React and reduxReact and redux
React and redux
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjs
 
React web development
React web developmentReact web development
React web development
 

Ähnlich wie React - Start learning today

react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react jsStephieJohn
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React TogetherSebastian Pederiva
 
React Best Practices All Developers Should Follow in 2024.pdf
React Best Practices All Developers Should Follow in 2024.pdfReact Best Practices All Developers Should Follow in 2024.pdf
React Best Practices All Developers Should Follow in 2024.pdfBOSC Tech Labs
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - Reactrbl002
 
What are the components in React?
What are the components in React?What are the components in React?
What are the components in React?BOSC Tech Labs
 
How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react jsBOSC Tech Labs
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react jsdhanushkacnd
 
GDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSGDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSPratik Majumdar
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)tuanpa206
 

Ähnlich wie React - Start learning today (20)

react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
ReactJS
ReactJSReactJS
ReactJS
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Combining Angular and React Together
Combining Angular and React TogetherCombining Angular and React Together
Combining Angular and React Together
 
ReactJS.ppt
ReactJS.pptReactJS.ppt
ReactJS.ppt
 
React js
React jsReact js
React js
 
Intro react js
Intro react jsIntro react js
Intro react js
 
React Best Practices All Developers Should Follow in 2024.pdf
React Best Practices All Developers Should Follow in 2024.pdfReact Best Practices All Developers Should Follow in 2024.pdf
React Best Practices All Developers Should Follow in 2024.pdf
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
What are the components in React?
What are the components in React?What are the components in React?
What are the components in React?
 
Let's react - Meetup
Let's react - MeetupLet's react - Meetup
Let's react - Meetup
 
Getting Started With ReactJS
Getting Started With ReactJSGetting Started With ReactJS
Getting Started With ReactJS
 
How to create components in react js
How to create components in react jsHow to create components in react js
How to create components in react js
 
Intro to React.js
Intro to React.jsIntro to React.js
Intro to React.js
 
Build web apps with react js
Build web apps with react jsBuild web apps with react js
Build web apps with react js
 
GDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSGDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJS
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)
 
React JS .NET
React JS .NETReact JS .NET
React JS .NET
 

Kürzlich hochgeladen

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Kürzlich hochgeladen (20)

08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

React - Start learning today

  • 1. ReactA JavaScript library for building user interfaces NITIN TYAGI Consulting Software Engineer https://www.linkedin.com/in/nitin-tyagi-37832798/
  • 2. React Agenda Session Introduction & Learning Philosophy Why use React? React Setup JSX & Rendering Elements React Parent/Child Components React Functional Components and Class components React Prop and State React Lifecycle Handling Events React Native : Introduction
  • 3. React Session Introduction & Learning Philosophy What is React? Trick is 3P….. Practice, Practice, Practice Learn by doing examples. Scenario based problems. Setup React environment and install new packages and play around. Download react community projects and check out Architecture and application. https://reactjs.org/community/examples.html Design your own project and Architecture.
  • 4. Why use React? • Virtual DOM. HTML is easy to Manipulate. Unfortunately, easily doesn’t mean quickly here. • Reusable Web Components. • Maintained by Facebook
  • 5. React Setup • Download and install Visual studio code IDE. Free, Cross platform and Opensource  https://code.visualstudio.com/download • Download and install Node Js for JavaScript runtime.  https://nodejs.org/en/ • Check npm latest is installed from above installation.  https://www.npmjs.com/get-npm • Create first React project by using below commands  npm install -g create-react-app  create-react-app my-app  cd my-app  npm start  http://localhost:3000
  • 6. React JSX & Rendering Elements • It is a syntax extension of JavaScript. • JSX allows us to write HTML in React. • For example consider below snippet. • Let go back to visual studio code to see JSX in action. const myelement = <h1>I Love JSX!</h1>; ReactDOM.render(myelement, document.getElementById('root')); const myelement = React.createElement('h1', {}, 'I do not use JSX!'); ReactDOM.render(myelement, document.getElementById('root')); Code Snippet : With JSX Code Snippet : Without JSX
  • 7. React Parent/Child Components ReactDOM.render( ,document.getElementById('root')); <App/> <WebPagebody /> <WebPagefooter /><WebPageheader /> <div>…..</div><header>..</header> <footer>...</footer>
  • 8. React React Functional Components and Class components • Components are independent and reusable bits of code. They serve the same purpose as JavaScript functions, but work in isolation and returns HTML via a render function. • The simplest way to define a component is to write a JavaScript function: function Welcome(props) { return <h1>Hello, {props.name}</h1>; } You can also use an ES6 class to define a component: class Welcome extends React.Component { render() { return <h1>Hello, {this.props.name}</h1>; } } • The above two components are equivalent from Reacts point of view. • Lets go back to visual studio code and explore more.
  • 9. React React Prop and State function Welcome(props) { return <h1>Hello, {props.name}</h1>; } const element = <Welcome name=“Nitin" />; ReactDOM.render( element, document.getElementById('root') ); • Props are arguments passed into React components. • Props are passed to components via HTML attributes. • Props are also how you pass data from one component to another, as parameters. Props are used to pass data from parent to child or by the component itself. They are immutable and thus will not be changed. State is used for mutable data, or data that will change. This is particularly useful for user input. • React components has a built-in state object. • The state object is where you store property values that belongs to the component. • When the state object changes, the component re-renders. class Car extends React.Component { constructor(props) { super(props); this.state = {Name: “Nitin"}; } render() { return ( <div> <h1>My Name</h1> </div> ); } }
  • 10. React Lifecycle • 3 major phases of React Lifecyle mounting, updating & unmounting • Lets see some examples in action. Mounting Updating Unmounting  constructor()  getDerivedStateFromPr ops()  render()  componentDidMount()  getDerivedStateFromPr ops()  shouldComponentUpd ate()  render()  getSnapshotBeforeUpd ate()  componentDidUpdate( )  componentWillUnmou nt()
  • 11. Handling Events Handling events with React elements is very similar to handling events on DOM elements. There are some syntactic differences: • React events are named using camelCase, rather than lowercase. • With JSX you pass a function as the event handler, rather than a string. button onClick={activateLasers}> Activate Lasers </button> < function ActionLink() { function handleClick(e) { e.preventDefault(); console.log('The link was clicked.’); } return ( <a href="#" onClick={handleClick}> Click me </a> ); }
  • 12. React React Native : A framework for building Native Apps Written in JavaScript—rendered with native code React primitives render to native platform UI, meaning your app uses the same native platform APIs other apps do. Many platforms, one React. Create platform-specific versions of components so a single codebase can share code across platforms. With React Native, one team can maintain two platforms and share a common technology—React. For more React Native advantages. Visit below link. https://www.oreilly.com/library/view/learning-react- native/9781491929049/ch01.html