SlideShare una empresa de Scribd logo
1 de 34
Let’s React
By Rajnish Katharotiya
Front-end Engineer @knovator
Topics
➔ Introduction of ReactJS.
➔ Component workflow.
➔ State management and useful life-cycles.
➔ React hooks.
➔ Server Side Rendering.
React Introduction
- React is an javascript library for building user
interface.
✅ Following
👆
✅ Following
React Introduction
- Initialise app.
npx create-react-app my-app //cra boilerplate
cd my-app
npm start
React Introduction
- Render app into Actual DOM.
ReactDOM.render(
<APP />,
document.getElementById('root')
)
<!DOCTYPE Html>
<html>
<head>...</head>
<body>
<div id="root" />
</body>
</html>
/public/index.html
/src/index.js
Compiled JSX syntax
What is JSX ??
JSX is basically a
syntax extension
of regular
JavaScript and is
used to create
React elements.
These elements are
then rendered to
the React DOM.
import React from 'react';
const App = () => ( <h1>Hello</h1> );
export default App;
/app.js
Components
class Profile extends Component {
state = {
followBtnText: 'Following'
};
render() {
const { state } = this;
return ( <Button {...state} /> );
}
}
/Profile.js - class
const Button = ({followBtnText}) =>
{
return (
<button>
{followBtnText}
</button>
);
};
/Button.js - functional
What is state?
In the React sense,
“state” is an object that
represents the parts of
the app that can
change. Each
component can
maintain its own state,
which lives in an object
called this. state
class Profile extends Component {
constructor(props){
super(props);
state = {
followBtnText : “Follow”
};
}
componentDidMount(){
this.setState({ followBtnText: “Following” })
}
render() {
const { state } = this;
return ( <Button {...state} /> );
}
}
/Profile.js
What is Props ?
class Profile extends Component {
constructor(props){
super(props);
state = { userName : 'John Doe' };
}
componentDidMount(){
this.setState({ ...this.props })
}
render() {
const { state } = this;
return ( <Name {...state} /> );
// return ( <Name userName={state.userName} />
)
}
/Profile.js
const Name = (props) => {
const { userName } = props;
return (
<h1>{userName}</h1>
);
};
/Name.js
Complexity of state/props
- Global State
management
- Store
- Actions
- Reducers
Redux
Lifecycles
- Each Component has lifecycle which you can monitor and
manipulate during its phases.
Useful Lifecycles
➔ componentWillMount()
➔ render()
➔ componentDidMount()
➔ componentWillReceiveProps() / componentDidUpdate()
➔ shouldComponentUpdate()
➔ componentWillUnmount()
React Hook
- Function to hook with state and Lifecycle of functional
component.
const Profile = () => {
const [ followStatus, setFollowStatus ] = useState(‘Follow’);
return ( <Button followStatus={followStatus} /> );
}
/Profile.js
React Hook - On Mount
const TopPicks = (props) => {
const [ list, setList ] = useState([]);
useEffect( () => {
const list = getTopPicksByUser();
setList(list);
}, [] );
return ( <Videos list={list} /> );
}
/TopPicks.js
React Hook - On Update
const VideoItem = (props) => {
const [ progress, setProgress ] =
useState(‘’);
useEffect( () => {
setProgress( props.progress );
}, [ props.progress ] );
return ( <ProgressBar progress={progress} /> );
}
/VideoItem.js
React Hook - On Unmount
const UserStatus = (props) => {
const [ staus, setStatus ] = useState(‘Active’);
useEffect( () => {
getUserStatus.subscribe(setStatus);
return () => getUserStatus.unsubscribe(setStatus);
}, [] );
return status;
}
/app.js
Server Side Rendering
- SSR is the ability of a front-end framework to render
markup while running on a back-end system.
➔ Performance benefit for our customer.
➔ Faster time for an initial page render.
➔ Consistent SEO performance.
Why SSR?
Overview - Client Side Rendering
- Browser download the javascript and then use it to
execute content.
<html lang="en">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, shrink-to-fit=no"
/>
<link href="/style.css" rel="stylesheet"/>
<title>Knovator</title>
<link rel="icon" href="/favicon.png" type="image/gif" sizes="16x16">
</head>
<body>
<div id="root"></div>
<script src="/index.js" type="text/javascript"></script>
<script src="/vendor.js" type="text/javascript"></script>
</body>
</html>
Understand with example
https://www.pokemon.com/
Pokemon - Get #1
Browser Server
<html lang="en">
<head>
<link href="/style.css" rel="stylesheet"/>
</head>
<body>
<div id="root"></div>
<script src="/index.js" type="text/javascript"></script>
</body>
</html>
GET /
index.html
Pokemon - View #1
https://www.pokemon.com/
Pokemon - Get #2
Browser Server
GET /index.js
index.js
Pokemon - View #2
https://www.pokemon.com/
- Thousands lines of
javascript code
prased.
- Script execution
begin.
- ReactDOM render.
Pokemon - Get #3
Browser
Pokemon
Server
GET /api/pokemon
Pokemon
https://www.pokemon.com/
Request Overview
https://www.pokemon.com/ https://www.pokemon.com/ https://www.pokemon.com/ https://www.pokemon.com/
Server
4. Meaningful Presentation3. Static Content Render2. Blank Screen1. Blank Screen
Overview - Server Side Rendering
<html lang="en">
<head>
<link href="/style.css" rel="stylesheet"/>
</head>
<body>
<div id="root">
<div class="root-component">
<h1 class="title"> React Meetup </h1>
</div>
</div>
<script src="/index.js" type="text/javascript"></script>
</body>
</html>
- Server(NodeJs) renders the App and generates the content
at server-side and returns the generated content.
Request Overview
https://www.pokemon.com/
21
https://www.pokemon.com/
GET /
● Server get
request
● Server gets
pokemon from DB
● Server renders
HTML
Downloads js and Renders DOM
- DOM Renders again
on client-side.
- Verify state and
attach handlers
CSR - Lighthouse Report
SSR - Lighthouse Report
CSR - Performance Report
SSR - Performance Report
“A good discussion increases the
dimensions of everyone who takes part”
- From Randolph Bourne
Have a great Day!

Más contenido relacionado

La actualidad más candente

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introductionTania Gonzales
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architectureGabriele Falace
 
The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014Matt Raible
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)Nitya Narasimhan
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)Gary Arora
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginnersMunir Hoque
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedStéphane Bégaudeau
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)Binary Studio
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentationnishasowdri
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introductionLuigi De Russis
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular jsAayush Shrestha
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeBrajesh Yadav
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architectureMichael He
 

La actualidad más candente (20)

AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Angular js
Angular jsAngular js
Angular js
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014The Art of AngularJS - DeRailed 2014
The Art of AngularJS - DeRailed 2014
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)AngularJS Deep Dives (NYC GDG Apr 2013)
AngularJS Deep Dives (NYC GDG Apr 2013)
 
AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)AngularJS - What is it & Why is it awesome ? (with demos)
AngularJS - What is it & Why is it awesome ? (with demos)
 
Angular js for beginners
Angular js for beginnersAngular js for beginners
Angular js for beginners
 
AngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get startedAngularJS 101 - Everything you need to know to get started
AngularJS 101 - Everything you need to know to get started
 
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
React vs Angular: ups & downs (speaker Oleksandr Kovalov, Binary Studio)
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
ReactJs presentation
ReactJs presentationReactJs presentation
ReactJs presentation
 
React JS part 1
React JS part 1React JS part 1
React JS part 1
 
AngularJS: an introduction
AngularJS: an introductionAngularJS: an introduction
AngularJS: an introduction
 
The AngularJS way
The AngularJS wayThe AngularJS way
The AngularJS way
 
Understanding angular js
Understanding angular jsUnderstanding angular js
Understanding angular js
 
React / Redux Architectures
React / Redux ArchitecturesReact / Redux Architectures
React / Redux Architectures
 
Understanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scopeUnderstanding angular js $rootscope and $scope
Understanding angular js $rootscope and $scope
 
ReactJS for Beginners
ReactJS for BeginnersReactJS for Beginners
ReactJS for Beginners
 
Angularjs architecture
Angularjs architectureAngularjs architecture
Angularjs architecture
 

Similar a Let's react - Meetup

React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and SymfonyIgnacio Martín
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs[T]echdencias
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsVinícius de Moraes
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docsAbhi166803
 
Component level caching with react
Component level caching with reactComponent level caching with react
Component level caching with reactAnusheelSingh2
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Elyse Kolker Gordon
 
React for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectReact for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectAtlassian
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to ReactJean Carlo Emer
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Eliran Eliassy
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Luciano Mammino
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and reduxCuong Ho
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix Chen Lerner
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)Jo Cranford
 

Similar a Let's react - Meetup (20)

ReactJS
ReactJSReactJS
ReactJS
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
Server side rendering with React and Symfony
Server side rendering with React and SymfonyServer side rendering with React and Symfony
Server side rendering with React and Symfony
 
React & Redux for noobs
React & Redux for noobsReact & Redux for noobs
React & Redux for noobs
 
Course CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.jsCourse CodeSchool - Shaping up with Angular.js
Course CodeSchool - Shaping up with Angular.js
 
React js
React jsReact js
React js
 
243329387 angular-docs
243329387 angular-docs243329387 angular-docs
243329387 angular-docs
 
Component level caching with react
Component level caching with reactComponent level caching with react
Component level caching with react
 
Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017Building Universal Web Apps with React ForwardJS 2017
Building Universal Web Apps with React ForwardJS 2017
 
React for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectReact for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence Connect
 
A full introductory guide to React
A full introductory guide to ReactA full introductory guide to React
A full introductory guide to React
 
Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics Angular server side rendering - Strategies & Technics
Angular server side rendering - Strategies & Technics
 
React
React React
React
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
 
Introduction to react and redux
Introduction to react and reduxIntroduction to react and redux
Introduction to react and redux
 
Os Haase
Os HaaseOs Haase
Os Haase
 
React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix React basic by Yoav Amit, Wix
React basic by Yoav Amit, Wix
 
Intro react js
Intro react jsIntro react js
Intro react js
 
React on Rails - RailsConf 2017 (Phoenix)
 React on Rails - RailsConf 2017 (Phoenix) React on Rails - RailsConf 2017 (Phoenix)
React on Rails - RailsConf 2017 (Phoenix)
 
React outbox
React outboxReact outbox
React outbox
 

Último

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

Let's react - Meetup

  • 1. Let’s React By Rajnish Katharotiya Front-end Engineer @knovator
  • 2. Topics ➔ Introduction of ReactJS. ➔ Component workflow. ➔ State management and useful life-cycles. ➔ React hooks. ➔ Server Side Rendering.
  • 3. React Introduction - React is an javascript library for building user interface. ✅ Following 👆 ✅ Following
  • 4. React Introduction - Initialise app. npx create-react-app my-app //cra boilerplate cd my-app npm start
  • 5. React Introduction - Render app into Actual DOM. ReactDOM.render( <APP />, document.getElementById('root') ) <!DOCTYPE Html> <html> <head>...</head> <body> <div id="root" /> </body> </html> /public/index.html /src/index.js Compiled JSX syntax
  • 6. What is JSX ?? JSX is basically a syntax extension of regular JavaScript and is used to create React elements. These elements are then rendered to the React DOM. import React from 'react'; const App = () => ( <h1>Hello</h1> ); export default App; /app.js
  • 7. Components class Profile extends Component { state = { followBtnText: 'Following' }; render() { const { state } = this; return ( <Button {...state} /> ); } } /Profile.js - class const Button = ({followBtnText}) => { return ( <button> {followBtnText} </button> ); }; /Button.js - functional
  • 8. What is state? In the React sense, “state” is an object that represents the parts of the app that can change. Each component can maintain its own state, which lives in an object called this. state class Profile extends Component { constructor(props){ super(props); state = { followBtnText : “Follow” }; } componentDidMount(){ this.setState({ followBtnText: “Following” }) } render() { const { state } = this; return ( <Button {...state} /> ); } } /Profile.js
  • 9. What is Props ? class Profile extends Component { constructor(props){ super(props); state = { userName : 'John Doe' }; } componentDidMount(){ this.setState({ ...this.props }) } render() { const { state } = this; return ( <Name {...state} /> ); // return ( <Name userName={state.userName} /> ) } /Profile.js const Name = (props) => { const { userName } = props; return ( <h1>{userName}</h1> ); }; /Name.js
  • 11. - Global State management - Store - Actions - Reducers Redux
  • 12. Lifecycles - Each Component has lifecycle which you can monitor and manipulate during its phases.
  • 13. Useful Lifecycles ➔ componentWillMount() ➔ render() ➔ componentDidMount() ➔ componentWillReceiveProps() / componentDidUpdate() ➔ shouldComponentUpdate() ➔ componentWillUnmount()
  • 14. React Hook - Function to hook with state and Lifecycle of functional component. const Profile = () => { const [ followStatus, setFollowStatus ] = useState(‘Follow’); return ( <Button followStatus={followStatus} /> ); } /Profile.js
  • 15. React Hook - On Mount const TopPicks = (props) => { const [ list, setList ] = useState([]); useEffect( () => { const list = getTopPicksByUser(); setList(list); }, [] ); return ( <Videos list={list} /> ); } /TopPicks.js
  • 16. React Hook - On Update const VideoItem = (props) => { const [ progress, setProgress ] = useState(‘’); useEffect( () => { setProgress( props.progress ); }, [ props.progress ] ); return ( <ProgressBar progress={progress} /> ); } /VideoItem.js
  • 17. React Hook - On Unmount const UserStatus = (props) => { const [ staus, setStatus ] = useState(‘Active’); useEffect( () => { getUserStatus.subscribe(setStatus); return () => getUserStatus.unsubscribe(setStatus); }, [] ); return status; } /app.js
  • 18. Server Side Rendering - SSR is the ability of a front-end framework to render markup while running on a back-end system. ➔ Performance benefit for our customer. ➔ Faster time for an initial page render. ➔ Consistent SEO performance. Why SSR?
  • 19. Overview - Client Side Rendering - Browser download the javascript and then use it to execute content. <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /> <link href="/style.css" rel="stylesheet"/> <title>Knovator</title> <link rel="icon" href="/favicon.png" type="image/gif" sizes="16x16"> </head> <body> <div id="root"></div> <script src="/index.js" type="text/javascript"></script> <script src="/vendor.js" type="text/javascript"></script> </body> </html>
  • 21. Pokemon - Get #1 Browser Server <html lang="en"> <head> <link href="/style.css" rel="stylesheet"/> </head> <body> <div id="root"></div> <script src="/index.js" type="text/javascript"></script> </body> </html> GET / index.html
  • 22. Pokemon - View #1 https://www.pokemon.com/
  • 23. Pokemon - Get #2 Browser Server GET /index.js index.js
  • 24. Pokemon - View #2 https://www.pokemon.com/ - Thousands lines of javascript code prased. - Script execution begin. - ReactDOM render.
  • 25. Pokemon - Get #3 Browser Pokemon Server GET /api/pokemon Pokemon https://www.pokemon.com/
  • 26. Request Overview https://www.pokemon.com/ https://www.pokemon.com/ https://www.pokemon.com/ https://www.pokemon.com/ Server 4. Meaningful Presentation3. Static Content Render2. Blank Screen1. Blank Screen
  • 27. Overview - Server Side Rendering <html lang="en"> <head> <link href="/style.css" rel="stylesheet"/> </head> <body> <div id="root"> <div class="root-component"> <h1 class="title"> React Meetup </h1> </div> </div> <script src="/index.js" type="text/javascript"></script> </body> </html> - Server(NodeJs) renders the App and generates the content at server-side and returns the generated content.
  • 28. Request Overview https://www.pokemon.com/ 21 https://www.pokemon.com/ GET / ● Server get request ● Server gets pokemon from DB ● Server renders HTML Downloads js and Renders DOM - DOM Renders again on client-side. - Verify state and attach handlers
  • 33. “A good discussion increases the dimensions of everyone who takes part” - From Randolph Bourne
  • 34. Have a great Day!

Notas del editor

  1. Hey everybody, Today we will talk about few concepts of React. In this meet-up, i would like to discuss topics of beginner to expert level. So, before going further let me introduce mysef, i’m rajnish katharotiya working here at knovator as an front-end engineer. And has been developing react applications from past 1.5 years. In my one and half year of journy i learnt many stuffs about react implementations and best practices. So, let’s just dive into topic which we are gonna cover and discuss together in this meetup.
  2. This top five topics i picked to discuss, where first one is introduction of reactjs, component workflow to get basic idea of react, some of us is totally new to react so this will help them to get understand why we should using it and what is it advantages. Then next state management and useful life-cycles is there, who's already started react for them this can be best practices. This all topics needed to become reactjs developer. While moving further we have next booming topic called React Hooks, this one is launched few months ago from 16.8v of react with some exciting features. And finally more attractive topic of all comes in line is Server Side Rendering aka SSR which also one of necessary tech which beneficial to know with react. Now let’s see all one by one ….
  3. So, FIrst React is a javascript library which use to build a user interface of the web app. The main advantage of this platform is to update UI changes through Virtual DOM. Here is one example of it. ……. In old days, when we wanted to update a status of just the number of comments of a particular page user has to reload whole DOM by refreshing page. Whereas with the help of this virtual DOM, it will update just only text of button-like follow to following. With no time, it’ll update our viewport without re-rendering actual DOM.
  4. React is a javascript library which use to build a user interface of the web app. The main advantage of this platform is to update UI changes through Virtual DOM. Here is one example of it. ……. In old days, when we wanted to update a status of just the number of comments of a particular page user has to reload whole DOM by refreshing page. While the help of this virtual DOM, it will update just only text of button-like follow to following. With no time, it’ll update our viewport without re-rendering actual DOM.
  5. React is a javascript library which use to build a user interface of the web app. The main advantage of this platform is to update UI changes through Virtual DOM. Here is one example of it. ……. In old days, when we wanted to update a status of just the number of comments of a particular page user has to reload whole DOM by refreshing page. While the help of this virtual DOM, it will update just only text of button-like follow to following. With no time, it’ll update our viewport without re-rendering actual DOM.