SlideShare ist ein Scribd-Unternehmen logo
1 von 32
ReactJS basics
An enticing introduction
We will talk about
 What is React?
 Why do people use React?
 Pre-requisites to learning React
 A tour of React eco-system
 React “Hello World” in 3 mins
 Some basic concepts
 The path forward
What is React?
 A declarative, efficient, and flexible JavaScript library for building user interfaces
 Designed for gradual adoption, and you can use as little or as much React as you
need
People use it for a presentation library
https://github.com/FormidableLabs/spectacle
Virtual Reality
ReactVR rotating boxes
To build a shopping cart
https://github.com/jeffersonRibeiro/react-shopping-cart
Online editors
https://codesandbox.io/s/
Create physics based animation library
https://github.com/react-spring/react-spring
Create word documents
https://github.com/nitin42/redocx
Mobile apps and games of course
And many more cool things…
Why do people use
React?
 Awesome documentation & support
 That has led to a wonderful ecosystem
 Great dev tools
 Efficient DOM management
Source: https://codesandbox.io/search?refinementList%5Btemplate%5D=&page=1
More numbers…
Don’t believe me on this though…
https://2018.stateofjs.com/front-end-frameworks/overview/
But, how is the ReactJS market in India?
Ok, but how is it in Ahmedabad?
Prerequisites
Basic would suffice
Advanced would help grab faster
React eco-system
React ecosystem
Lets understand through a discussion between two friends.
Anil asks for suggestions from his friend Biju on technology he should use for fetching
API data and displaying it on his web app.
An animated version of blog How it feels to learn javascript in 2016
I was thinking
maybe using
jQuery to fetch
and display the
data?
Oh my god no,
no one uses
jQuery anymore.
You should try
learning React,
it’s 2016
Oh, OK. What’s
React?
A super cool
library made by
some guys at
Facebook, it
brings control &
performance to
your application,
by allowing you to
handle any view
changes very
easily
That sounds neat.
Can I use React to
display data from
the server?
Yeah, but first
you need to add
React and React
DOM as a
library in your
webpage. Why two
libraries?
So one is the
actual library and
the second one is
for manipulating
the DOM, which
now you can
describe in JSX.
JSX? What is JSX?
JSX is just a
JavaScript syntax
extension that
looks pretty much
like XML. It’s kind
of another way to
describe the DOM,
think of it as a
better HTML.
If I add these two
libraries then I can
use React?
Not quite. You
need to add
Babel, and then
you are able to
use React.
Another library?
What’s Babel?
Babel is a
transpiler that
allows you to
target specific
versions of
JavaScript, while
you code in any
version of
JavaScript. Babel
allows you to
code in
ES2016+ rather
than ES5
ES5, ES2016+? I’m
getting lost over
here.
ES5 stands for
ECMAScript 5. It’s
the edition that
has most people
target since it has
been
implemented by
most browsers
nowadays.
ECMAScript?
Its the scripting
standard
JavaScript was
based on in 1999
after its initial
release in 1995.
We have, like, 7
editions of this
implementation.
7 editions. For
real. And ES5 and
ES2016+ are?
The fifth and
seventh edition
respectively.
Wait, what
happened with
the sixth?
Each edition is a
superset of the
previous one, so
if you are using
ES2016+, you
are using all the
features of the
previous
versions.
And why use
ES2016+ over ES6
then?
You could use ES6,
but to use cool
features like async
and await, you need
to use ES2016+.
Otherwise you are
stuck with ES6
generators with
coroutines to block
asynchronous calls
for proper control
flow.
All these names
are confusing.
Look, I’m just
loading a bunch
of data from a
server, I used to
be able to just
include jQuery
from a CDN and
just get the data
with AJAX calls,
why can’t I just do
that?
It’s 2016 man,
no one uses
jQuery anymore,
it ends up in a
bunch of
spaghetti code.
Everyone knows
that.
Right. So my
alternative is to
load three libraries
to fetch data and
display a HTML
table.
Well, you
include those
three libraries
but bundle
them up with a
module
manager to load
only one file.
And what’s a
module manager?
The definition
depends on the
environment, but in
the web we usually
mean anything that
supports AMD or
CommonJS modules
And AMD and
CommonJS are…
Ways to describe
how multiple
JavaScript libraries
should interact. You
know, import and
requires? You can
write multiple
JavaScript files using
AMD or CommonJS
API & you can use
something like
Browserify to
bundle them up
OK, that makes
sense… What is
Browserify?
A tool that allows
you to bundle
dependencies to files
that can be run in
the browser. It was
created because
most people publish
those dependencies
in the npm registry.
So I need to
download the
libraries from npm
then?
Yes. so if you
want to use
React , you
download the
React module
and import it in
your code. You
can do that for
almost every
popular
JavaScript
library.
Oh, like Angular!
Angular is so 2015.
But yes. Angular
would be there,
alongside VueJS or
RxJS and other cool
2016 libraries. Want
to learn about
those?
npm registry?
It’s a very big
public repository
where smart
people put code
and dependencies
as modules
Is the learning curve so steep?
 https://github.com/kamranahmedse/developer-roadmap
Do not feel so overwhelming. Not yet.
https://www.youtube.com/watch?v=mbiryVTIJ4Q
React “Hello World” in 3 minutes
Some basic concepts
 React components – Describe how a section of UI will appear based on the props
passed. Eg: Label, ShoppingCard, CreateUser
- Component is just a function/class. props are arguments.
 Class in javascript are actually Functions
 And Functions in javascript are actually Objects
- And so Class & Functions both can be stateful
Sample ReactJS component tree
Some basic concepts
Function to add 2 nos
add(2, 5)
What if I want total of 3 & 7
add(3,7)
React button component
<Button>Submit</Button>
What if I want to display a spinner on click?
<Button spinner=true>Submit</Button>
The path forward
 JSX semantics
 Stateful & Stateless components
 State & how to change it
 React advanced patterns
 React life cycle
 Context & Ref
 React Hooks
 Using developer tools
 Redux (External library for state management)
 React Router
And learning never stops…

Weitere ähnliche Inhalte

Was ist angesagt? (20)

Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
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
 
Workshop React.js
Workshop React.jsWorkshop React.js
Workshop React.js
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React js
React jsReact js
React js
 
Introduction to React
Introduction to ReactIntroduction to React
Introduction to React
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
ReactJS
ReactJSReactJS
ReactJS
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
React js
React jsReact js
React js
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 
Redux workshop
Redux workshopRedux workshop
Redux workshop
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
React js
React jsReact js
React js
 
Introduction to React JS
Introduction to React JSIntroduction to React JS
Introduction to React JS
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
ReactJs
ReactJsReactJs
ReactJs
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 

Ähnlich wie React js basics

9 reasons why programmers should learn react native
9 reasons why programmers should learn react native9 reasons why programmers should learn react native
9 reasons why programmers should learn react nativeReact Sharing
 
three_software_development_trends_to_follow_in_2016
three_software_development_trends_to_follow_in_2016three_software_development_trends_to_follow_in_2016
three_software_development_trends_to_follow_in_2016Interbrand
 
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfKaty Slemon
 
React.js alternatives modern web frameworks and lightweight java script libr...
React.js alternatives  modern web frameworks and lightweight java script libr...React.js alternatives  modern web frameworks and lightweight java script libr...
React.js alternatives modern web frameworks and lightweight java script libr...Katy Slemon
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaStack Learner
 
Comprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptxComprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptx75waytechnologies
 
Type script vs javascript come face to face in battleground
Type script vs javascript come face to face in battlegroundType script vs javascript come face to face in battleground
Type script vs javascript come face to face in battlegroundKaty Slemon
 
5 java script frameworks to watch in 2017
5 java script frameworks to watch in 20175 java script frameworks to watch in 2017
5 java script frameworks to watch in 2017Designveloper
 
Powerful tools for building web solutions
Powerful tools for building web solutionsPowerful tools for building web solutions
Powerful tools for building web solutionsAndrea Tino
 
Sandeep Chauhan | Explore the major differences between react js and react na...
Sandeep Chauhan | Explore the major differences between react js and react na...Sandeep Chauhan | Explore the major differences between react js and react na...
Sandeep Chauhan | Explore the major differences between react js and react na...Sandeep Chauhan
 
Techpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdfTechpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdfTechpaathshala
 
Skill practical javascript diy projects
Skill practical javascript diy projectsSkill practical javascript diy projects
Skill practical javascript diy projectsSkillPracticalEdTech
 
Guide to Using React Router V6 in React Apps.pdf
Guide to Using React Router V6 in React Apps.pdfGuide to Using React Router V6 in React Apps.pdf
Guide to Using React Router V6 in React Apps.pdfAdarshMathuri
 
React native vs react js
React native vs react jsReact native vs react js
React native vs react jsJessica655282
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | IntroductionJohnTaieb
 
React in Action ( PDFDrive ).pdf
React in Action ( PDFDrive ).pdfReact in Action ( PDFDrive ).pdf
React in Action ( PDFDrive ).pdfalmako2
 

Ähnlich wie React js basics (20)

9 reasons why programmers should learn react native
9 reasons why programmers should learn react native9 reasons why programmers should learn react native
9 reasons why programmers should learn react native
 
three_software_development_trends_to_follow_in_2016
three_software_development_trends_to_follow_in_2016three_software_development_trends_to_follow_in_2016
three_software_development_trends_to_follow_in_2016
 
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdfReact Alternatives Frameworks- Lightweight Javascript Libraries.pdf
React Alternatives Frameworks- Lightweight Javascript Libraries.pdf
 
React.js alternatives modern web frameworks and lightweight java script libr...
React.js alternatives  modern web frameworks and lightweight java script libr...React.js alternatives  modern web frameworks and lightweight java script libr...
React.js alternatives modern web frameworks and lightweight java script libr...
 
Frontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In BanglaFrontend Development Bootcamp - React [Online & Offline] In Bangla
Frontend Development Bootcamp - React [Online & Offline] In Bangla
 
Handy JS Libraries
Handy JS LibrariesHandy JS Libraries
Handy JS Libraries
 
Js frameworks
Js frameworksJs frameworks
Js frameworks
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
Comprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptxComprehensive Guide to React Development 2022.pptx
Comprehensive Guide to React Development 2022.pptx
 
Type script vs javascript come face to face in battleground
Type script vs javascript come face to face in battlegroundType script vs javascript come face to face in battleground
Type script vs javascript come face to face in battleground
 
5 java script frameworks to watch in 2017
5 java script frameworks to watch in 20175 java script frameworks to watch in 2017
5 java script frameworks to watch in 2017
 
Powerful tools for building web solutions
Powerful tools for building web solutionsPowerful tools for building web solutions
Powerful tools for building web solutions
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
 
Sandeep Chauhan | Explore the major differences between react js and react na...
Sandeep Chauhan | Explore the major differences between react js and react na...Sandeep Chauhan | Explore the major differences between react js and react na...
Sandeep Chauhan | Explore the major differences between react js and react na...
 
Techpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdfTechpaathshala ReactJS .pdf
Techpaathshala ReactJS .pdf
 
Skill practical javascript diy projects
Skill practical javascript diy projectsSkill practical javascript diy projects
Skill practical javascript diy projects
 
Guide to Using React Router V6 in React Apps.pdf
Guide to Using React Router V6 in React Apps.pdfGuide to Using React Router V6 in React Apps.pdf
Guide to Using React Router V6 in React Apps.pdf
 
React native vs react js
React native vs react jsReact native vs react js
React native vs react js
 
Front End Development | Introduction
Front End Development | IntroductionFront End Development | Introduction
Front End Development | Introduction
 
React in Action ( PDFDrive ).pdf
React in Action ( PDFDrive ).pdfReact in Action ( PDFDrive ).pdf
React in Action ( PDFDrive ).pdf
 

Kürzlich hochgeladen

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
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
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
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
 
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
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
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...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
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
 
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
 

React js basics

  • 2. We will talk about  What is React?  Why do people use React?  Pre-requisites to learning React  A tour of React eco-system  React “Hello World” in 3 mins  Some basic concepts  The path forward
  • 3. What is React?  A declarative, efficient, and flexible JavaScript library for building user interfaces  Designed for gradual adoption, and you can use as little or as much React as you need
  • 4. People use it for a presentation library https://github.com/FormidableLabs/spectacle
  • 6. To build a shopping cart https://github.com/jeffersonRibeiro/react-shopping-cart
  • 8. Create physics based animation library https://github.com/react-spring/react-spring
  • 10. Mobile apps and games of course
  • 11. And many more cool things…
  • 12. Why do people use React?  Awesome documentation & support  That has led to a wonderful ecosystem  Great dev tools  Efficient DOM management Source: https://codesandbox.io/search?refinementList%5Btemplate%5D=&page=1
  • 14. Don’t believe me on this though… https://2018.stateofjs.com/front-end-frameworks/overview/
  • 15. But, how is the ReactJS market in India?
  • 16. Ok, but how is it in Ahmedabad?
  • 19. React ecosystem Lets understand through a discussion between two friends. Anil asks for suggestions from his friend Biju on technology he should use for fetching API data and displaying it on his web app. An animated version of blog How it feels to learn javascript in 2016
  • 20. I was thinking maybe using jQuery to fetch and display the data? Oh my god no, no one uses jQuery anymore. You should try learning React, it’s 2016 Oh, OK. What’s React? A super cool library made by some guys at Facebook, it brings control & performance to your application, by allowing you to handle any view changes very easily That sounds neat. Can I use React to display data from the server? Yeah, but first you need to add React and React DOM as a library in your webpage. Why two libraries? So one is the actual library and the second one is for manipulating the DOM, which now you can describe in JSX.
  • 21. JSX? What is JSX? JSX is just a JavaScript syntax extension that looks pretty much like XML. It’s kind of another way to describe the DOM, think of it as a better HTML. If I add these two libraries then I can use React? Not quite. You need to add Babel, and then you are able to use React. Another library? What’s Babel? Babel is a transpiler that allows you to target specific versions of JavaScript, while you code in any version of JavaScript. Babel allows you to code in ES2016+ rather than ES5 ES5, ES2016+? I’m getting lost over here. ES5 stands for ECMAScript 5. It’s the edition that has most people target since it has been implemented by most browsers nowadays.
  • 22. ECMAScript? Its the scripting standard JavaScript was based on in 1999 after its initial release in 1995. We have, like, 7 editions of this implementation. 7 editions. For real. And ES5 and ES2016+ are? The fifth and seventh edition respectively. Wait, what happened with the sixth? Each edition is a superset of the previous one, so if you are using ES2016+, you are using all the features of the previous versions. And why use ES2016+ over ES6 then? You could use ES6, but to use cool features like async and await, you need to use ES2016+. Otherwise you are stuck with ES6 generators with coroutines to block asynchronous calls for proper control flow.
  • 23. All these names are confusing. Look, I’m just loading a bunch of data from a server, I used to be able to just include jQuery from a CDN and just get the data with AJAX calls, why can’t I just do that? It’s 2016 man, no one uses jQuery anymore, it ends up in a bunch of spaghetti code. Everyone knows that.
  • 24. Right. So my alternative is to load three libraries to fetch data and display a HTML table. Well, you include those three libraries but bundle them up with a module manager to load only one file. And what’s a module manager? The definition depends on the environment, but in the web we usually mean anything that supports AMD or CommonJS modules And AMD and CommonJS are… Ways to describe how multiple JavaScript libraries should interact. You know, import and requires? You can write multiple JavaScript files using AMD or CommonJS API & you can use something like Browserify to bundle them up OK, that makes sense… What is Browserify? A tool that allows you to bundle dependencies to files that can be run in the browser. It was created because most people publish those dependencies in the npm registry.
  • 25. So I need to download the libraries from npm then? Yes. so if you want to use React , you download the React module and import it in your code. You can do that for almost every popular JavaScript library. Oh, like Angular! Angular is so 2015. But yes. Angular would be there, alongside VueJS or RxJS and other cool 2016 libraries. Want to learn about those? npm registry? It’s a very big public repository where smart people put code and dependencies as modules
  • 26. Is the learning curve so steep?  https://github.com/kamranahmedse/developer-roadmap
  • 27. Do not feel so overwhelming. Not yet. https://www.youtube.com/watch?v=mbiryVTIJ4Q
  • 28. React “Hello World” in 3 minutes
  • 29. Some basic concepts  React components – Describe how a section of UI will appear based on the props passed. Eg: Label, ShoppingCard, CreateUser - Component is just a function/class. props are arguments.  Class in javascript are actually Functions  And Functions in javascript are actually Objects - And so Class & Functions both can be stateful
  • 31. Some basic concepts Function to add 2 nos add(2, 5) What if I want total of 3 & 7 add(3,7) React button component <Button>Submit</Button> What if I want to display a spinner on click? <Button spinner=true>Submit</Button>
  • 32. The path forward  JSX semantics  Stateful & Stateless components  State & how to change it  React advanced patterns  React life cycle  Context & Ref  React Hooks  Using developer tools  Redux (External library for state management)  React Router And learning never stops…