SlideShare a Scribd company logo
1 of 45
Download to read offline
React Fundamentals
In addition to some full-stack development!
$whoami
> Jarrod Servilla
> CSSC Tech Director
> Daniel Laufer
> GDSC Workshop lead
> Milind Vishnoi
> GDSC Workshop lead
What youĘźll learn
● What is React?
● What is JSX?
● Creating reusable react components
● Dynamic rendering
● Component lifecycle
● React hooks & why we use them
● Full stack development fundamentals
● Networking protocol basics (http)
youĘźll create your own full
stack app!
and most importantly...
(kind of)
important resources
source code: https://github.com/utm-cssc/full-stack-react-workshop
gdsc workshops: https://github.com/Daniel-Laufer/GDSC-UTM-Workshops
cssc site: https://cssc.utm.utoronto.ca/
if you’re coding along with us:
● an ide (vscode)
● node.js
● docker
What is React?
● a declarative, component-based
front-end javascript library developed
by Facebook
● enables developers to build modern,
sleek, fast applications with a modular
infrastructure
● react is by far the most popular front-end
javascript library/framework!
Who uses React?
And soooooooo many more!
Why should you use react?
● can organize parts of the UI into components that can be easily
reused
● users can interact with the website without refreshing it
○ Ex. dynamically rendering search results from a search query
● you want to make use of its rich ecosystem and large community
support
○ if you search “how do I do X with react”, odds are there will be many
relevant search results
○ there are tons of react libraries for you to use. For example:
react-spring allows you to add sophisticated, good-looking animations
into your apps
○ users can share their own components with the community by creating
packages
What are React Apps made of?
● Primary Javascript and JSX (a ‘syntax extension’ for
Javascript).
○ Note that you can use plain Javascript to write React code but
it’s much more difficult/messy
● JSX looks a lot like standard HTML
Let’s take a look at an example!
Say we want to create this
beautiful component ----- >
this is the Javascript and JSX code
needed to create this component
the raw html generated by this code. Looks extremely similar right?
Components
A React component is a JavaScript function that optionally
takes in inputs (props) and returns ONE JSX element (this one
element can have many children).
our simple TodoItem component
Using our component and
passing data (props) into it
* you can also create components using classes but we won’t discuss that in this workshop :)
Using components
components can be rendered in two ways:
with and without children.
return (
<Navbar />
<PageWrapper>
<Navbar />
</PageWrapper>
);
Here Navbar is a child of PageWrapper
Using components
● You can continue nesting components as much you’d like!
● For example...
<PageWrapper>
<Navbar />
<div>
<PageWrapper>
<Navbar />
<Navbar />
<Navbar />
</PageWrapper>
</div>
</PageWrapper>
JavaScript inside JSX components
you may have seen us wrap some portions of code in curly
braces i.e {...}. Why is that?
● here everything outside the ‘{..}’ is JSX, and everything inside is javascript.
● if we didn’t have the curly branches there, our javascript code would be
interpreted as a string and NOT code (ie “messages.reduce((prev, curr) ⇒
prev.concat(curr), "")”)
Before we get into coding, letĘźs take a
look at some interesting JavaScript
syntax you will see Jarrod use
two ways of writing functions in Javascript
think of these as being equivalent function definitions for this
workshop. (There are some more technical differences between
these two functions but don’t worry about them for now 😉)
using components: destructuring objects
here is a component that takes in
multiple props.
the { … } is called object
destructuring, which pulls out the
values from the props object and
exposes it to us as url, title, and
msg respectively.
● just think of javascript doing
this behind the scenes
automatically for you.
● a lot less coding for us!
destructuring objects: continued
Time to Code!
Dynamic rendering
how do we render based on input?
Dynamic rendering
Suppose you wanted to create a component like this that
contains an arbitrary amount of children
one of the strengths of react is that we can use javascript to
render React elements dynamically!
instead of doing this….
… do this!
It’s basically just a fancy for loop that generates a list of react elements!
Time to Code!
lifecycle + hooks
updating the view after modifications occur
component lifecycle
🌱 mounting: component initialization, and addition to dom
🔄 updating: when props/state of a component changes,
rerender!
⚰ unmount: cleanup component resources, remove from
dom
hooks
Hooks was introduced in React 16.8
Hooks let you use state and other React features
without writing a class.
why hooks?
● no one knows how “this”
works.
● organizing our
components by lifecycle
methods forces us to
sprinkle related logic
throughout our
components.
● Makes testing easier
useState
this react hook allows us to persist data across re-renders
(and forces a re-render when our state changes) in that
state!
In the example function
you can create a count
state for the component
using useState as shown.
You can use count to
access count within the
component.
useEffect
this react hook allows us to run code (fetching data,
updating state) when changes occur in the states
specified.
useEffect as componentDidMount
We can use ‘useEffect’ to implement
‘componentDidMount’ function.
useEffect as componentWillUnmount
We can use ‘useEffect’ to implement
‘componentWillUnmount’ function.
create custom hooks
When we need to use function logic in more than
one component we can extract that logic into
another function (hook).
A custom hook is a JavaScript function whose name
starts with ”use” and that may call other hooks.
for example: using a custom hook to fetch data for
different URL.
creating custom hooks
Custom hook
Using the custom hook
Time to Code!
full stack apps
how do we persist data?
Client Server Database
API: Application Programming Interface
createTodo(message)
deleteTodo(todoid)
editTodo(todoid, message, ...)
URL: Universal Resource Locator
/todos
/todos/<id>
/todos?todoid=<id>
/todos?maxPages=<num>
https://my-domain.api.com
HTTP: Hypertext Transfer Protocol
/todos/<id> [GET]
/todos/<id> [DEL]
/todos?todoid=<id> [GET]
/todos?maxPages=<num>
https://my-domain.api.com
200 OK: The response has succeeded!
201 Created: The request has succeeded, and the resource has been created (usually for POST)
400 Bad Request: The server could not understand the request due to invalid syntax
401 Unauthorized: The client is not allowed to get the requested response
404 Not Found: The server cannot find the requested resource
418 Iʼm a teapot: The server refuses to brew coffee because it is, permanently, a teapot.
500 Internal Server Error: The server has encountered an issue while processing your request
after issuing an http request, we expect to receive a status code and response body (typically
JSON). http statuses describe what the server did in response to the request.
api integration
connecting our frontend to our backend
Time to Code!
Thank you!
Any questions?

More Related Content

What's hot

[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 

What's hot (20)

React hooks
React hooksReact hooks
React hooks
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
React workshop
React workshopReact workshop
React workshop
 
Basics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdfBasics of React Hooks.pptx.pdf
Basics of React Hooks.pptx.pdf
 
ASP.NET MVC Presentation
ASP.NET MVC PresentationASP.NET MVC Presentation
ASP.NET MVC Presentation
 
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
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners
 
React JS & Functional Programming Principles
React JS & Functional Programming PrinciplesReact JS & Functional Programming Principles
React JS & Functional Programming Principles
 
React js
React jsReact js
React js
 
reactJS
reactJSreactJS
reactJS
 
React new features and intro to Hooks
React new features and intro to HooksReact new features and intro to Hooks
React new features and intro to Hooks
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
What is component in reactjs
What is component in reactjsWhat is component in reactjs
What is component in reactjs
 
React Class Components vs Functional Components: Which is Better?
React Class Components vs Functional Components: Which is Better?React Class Components vs Functional Components: Which is Better?
React Class Components vs Functional Components: Which is Better?
 
React-JS.pptx
React-JS.pptxReact-JS.pptx
React-JS.pptx
 
React js programming concept
React js programming conceptReact js programming concept
React js programming concept
 

Similar to Full Stack React Workshop [CSSC x GDSC]

React Basic and Advance || React Basic
React Basic and Advance   || React BasicReact Basic and Advance   || React Basic
React Basic and Advance || React Basic
rafaqathussainc077
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !
Ritesh Kumar
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
Rob Davarnia
 
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
janet736113
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
jobinThomas54
 

Similar to Full Stack React Workshop [CSSC x GDSC] (20)

GDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJSGDSC NITS Presents Kickstart into ReactJS
GDSC NITS Presents Kickstart into ReactJS
 
React JS: A Secret Preview
React JS: A Secret PreviewReact JS: A Secret Preview
React JS: A Secret Preview
 
React Native for multi-platform mobile applications
React Native for multi-platform mobile applicationsReact Native for multi-platform mobile applications
React Native for multi-platform mobile applications
 
React Basic and Advance || React Basic
React Basic and Advance   || React BasicReact Basic and Advance   || React Basic
React Basic and Advance || React Basic
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
Getting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular DeveloperGetting Started with React, When You’re an Angular Developer
Getting Started with React, When You’re an Angular Developer
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !
 
Learn react by Etietop Demas
Learn react by Etietop DemasLearn react by Etietop Demas
Learn react by Etietop Demas
 
Beginning MEAN Stack
Beginning MEAN StackBeginning MEAN Stack
Beginning MEAN Stack
 
Fewd week4 slides
Fewd week4 slidesFewd week4 slides
Fewd week4 slides
 
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.pptx
ReactJS.pptxReactJS.pptx
ReactJS.pptx
 
20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native20180518 QNAP Seminar - Introduction to React Native
20180518 QNAP Seminar - Introduction to React Native
 
Reactjs notes.pptx for web development- tutorial and theory
Reactjs  notes.pptx for web development- tutorial and theoryReactjs  notes.pptx for web development- tutorial and theory
Reactjs notes.pptx for web development- tutorial and theory
 
Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016Web Development with Delphi and React - ITDevCon 2016
Web Development with Delphi and React - ITDevCon 2016
 

More from GDSC UofT Mississauga

More from GDSC UofT Mississauga (20)

CSSC ML Workshop
CSSC ML WorkshopCSSC ML Workshop
CSSC ML Workshop
 
ICCIT Council × GDSC: UX / UI and Figma
ICCIT Council × GDSC: UX / UI and FigmaICCIT Council × GDSC: UX / UI and Figma
ICCIT Council × GDSC: UX / UI and Figma
 
Community Projects Info Session Fall 2023
Community Projects Info Session Fall 2023Community Projects Info Session Fall 2023
Community Projects Info Session Fall 2023
 
GDSC x Deerhacks - Origami Workshop
GDSC x Deerhacks - Origami WorkshopGDSC x Deerhacks - Origami Workshop
GDSC x Deerhacks - Origami Workshop
 
Reverse Engineering 101
Reverse Engineering 101Reverse Engineering 101
Reverse Engineering 101
 
Michael's OWASP Juice Shop Workshop
Michael's OWASP Juice Shop WorkshopMichael's OWASP Juice Shop Workshop
Michael's OWASP Juice Shop Workshop
 
MCSS × GDSC: Intro to Cybersecurity Workshop
MCSS × GDSC: Intro to Cybersecurity WorkshopMCSS × GDSC: Intro to Cybersecurity Workshop
MCSS × GDSC: Intro to Cybersecurity Workshop
 
Basics of C
Basics of CBasics of C
Basics of C
 
Discord Bot Workshop Slides
Discord Bot Workshop SlidesDiscord Bot Workshop Slides
Discord Bot Workshop Slides
 
Web Scraping Workshop
Web Scraping WorkshopWeb Scraping Workshop
Web Scraping Workshop
 
Devops Workshop
Devops WorkshopDevops Workshop
Devops Workshop
 
Express
ExpressExpress
Express
 
HTML_CSS_JS Workshop
HTML_CSS_JS WorkshopHTML_CSS_JS Workshop
HTML_CSS_JS Workshop
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
 
Docker workshop GDSC_CSSC
Docker workshop GDSC_CSSCDocker workshop GDSC_CSSC
Docker workshop GDSC_CSSC
 
Back-end (Flask_AWS)
Back-end (Flask_AWS)Back-end (Flask_AWS)
Back-end (Flask_AWS)
 
Git Init (Introduction to Git)
Git Init (Introduction to Git)Git Init (Introduction to Git)
Git Init (Introduction to Git)
 
Database Workshop Slides
Database Workshop SlidesDatabase Workshop Slides
Database Workshop Slides
 
ChatGPT General Meeting
ChatGPT General MeetingChatGPT General Meeting
ChatGPT General Meeting
 
Elon & Twitter General Meeting
Elon & Twitter General MeetingElon & Twitter General Meeting
Elon & Twitter General Meeting
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Recently uploaded (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
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
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
API Governance and Monetization - The evolution of API governance
API Governance and Monetization -  The evolution of API governanceAPI Governance and Monetization -  The evolution of API governance
API Governance and Monetization - The evolution of API governance
 
Choreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software EngineeringChoreo: Empowering the Future of Enterprise Software Engineering
Choreo: Empowering the Future of Enterprise Software Engineering
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 

Full Stack React Workshop [CSSC x GDSC]

  • 1. React Fundamentals In addition to some full-stack development!
  • 2. $whoami > Jarrod Servilla > CSSC Tech Director > Daniel Laufer > GDSC Workshop lead > Milind Vishnoi > GDSC Workshop lead
  • 3. What youĘźll learn ● What is React? ● What is JSX? ● Creating reusable react components ● Dynamic rendering ● Component lifecycle ● React hooks & why we use them ● Full stack development fundamentals ● Networking protocol basics (http)
  • 4. youĘźll create your own full stack app! and most importantly... (kind of)
  • 5. important resources source code: https://github.com/utm-cssc/full-stack-react-workshop gdsc workshops: https://github.com/Daniel-Laufer/GDSC-UTM-Workshops cssc site: https://cssc.utm.utoronto.ca/ if you’re coding along with us: ● an ide (vscode) ● node.js ● docker
  • 6. What is React? ● a declarative, component-based front-end javascript library developed by Facebook ● enables developers to build modern, sleek, fast applications with a modular infrastructure ● react is by far the most popular front-end javascript library/framework!
  • 7. Who uses React? And soooooooo many more!
  • 8. Why should you use react? ● can organize parts of the UI into components that can be easily reused ● users can interact with the website without refreshing it ○ Ex. dynamically rendering search results from a search query ● you want to make use of its rich ecosystem and large community support ○ if you search “how do I do X with react”, odds are there will be many relevant search results ○ there are tons of react libraries for you to use. For example: react-spring allows you to add sophisticated, good-looking animations into your apps ○ users can share their own components with the community by creating packages
  • 9. What are React Apps made of? ● Primary Javascript and JSX (a ‘syntax extension’ for Javascript). ○ Note that you can use plain Javascript to write React code but it’s much more difficult/messy ● JSX looks a lot like standard HTML Let’s take a look at an example!
  • 10. Say we want to create this beautiful component ----- > this is the Javascript and JSX code needed to create this component the raw html generated by this code. Looks extremely similar right?
  • 11.
  • 12. Components A React component is a JavaScript function that optionally takes in inputs (props) and returns ONE JSX element (this one element can have many children). our simple TodoItem component Using our component and passing data (props) into it * you can also create components using classes but we won’t discuss that in this workshop :)
  • 13. Using components components can be rendered in two ways: with and without children. return ( <Navbar /> <PageWrapper> <Navbar /> </PageWrapper> ); Here Navbar is a child of PageWrapper
  • 14. Using components ● You can continue nesting components as much you’d like! ● For example... <PageWrapper> <Navbar /> <div> <PageWrapper> <Navbar /> <Navbar /> <Navbar /> </PageWrapper> </div> </PageWrapper>
  • 15. JavaScript inside JSX components you may have seen us wrap some portions of code in curly braces i.e {...}. Why is that? ● here everything outside the ‘{..}’ is JSX, and everything inside is javascript. ● if we didn’t have the curly branches there, our javascript code would be interpreted as a string and NOT code (ie “messages.reduce((prev, curr) ⇒ prev.concat(curr), "")”)
  • 16. Before we get into coding, letĘźs take a look at some interesting JavaScript syntax you will see Jarrod use
  • 17. two ways of writing functions in Javascript think of these as being equivalent function definitions for this workshop. (There are some more technical differences between these two functions but don’t worry about them for now 😉)
  • 18. using components: destructuring objects here is a component that takes in multiple props. the { … } is called object destructuring, which pulls out the values from the props object and exposes it to us as url, title, and msg respectively.
  • 19. ● just think of javascript doing this behind the scenes automatically for you. ● a lot less coding for us! destructuring objects: continued
  • 21. Dynamic rendering how do we render based on input?
  • 22. Dynamic rendering Suppose you wanted to create a component like this that contains an arbitrary amount of children one of the strengths of react is that we can use javascript to render React elements dynamically!
  • 23. instead of doing this….
  • 24. … do this! It’s basically just a fancy for loop that generates a list of react elements!
  • 26. lifecycle + hooks updating the view after modifications occur
  • 27. component lifecycle 🌱 mounting: component initialization, and addition to dom 🔄 updating: when props/state of a component changes, rerender! ⚰ unmount: cleanup component resources, remove from dom
  • 28. hooks Hooks was introduced in React 16.8 Hooks let you use state and other React features without writing a class.
  • 29. why hooks? ● no one knows how “this” works. ● organizing our components by lifecycle methods forces us to sprinkle related logic throughout our components. ● Makes testing easier
  • 30. useState this react hook allows us to persist data across re-renders (and forces a re-render when our state changes) in that state! In the example function you can create a count state for the component using useState as shown. You can use count to access count within the component.
  • 31. useEffect this react hook allows us to run code (fetching data, updating state) when changes occur in the states specified.
  • 32. useEffect as componentDidMount We can use ‘useEffect’ to implement ‘componentDidMount’ function.
  • 33. useEffect as componentWillUnmount We can use ‘useEffect’ to implement ‘componentWillUnmount’ function.
  • 34. create custom hooks When we need to use function logic in more than one component we can extract that logic into another function (hook). A custom hook is a JavaScript function whose name starts with ”use” and that may call other hooks. for example: using a custom hook to fetch data for different URL.
  • 35. creating custom hooks Custom hook Using the custom hook
  • 37. full stack apps how do we persist data?
  • 39. API: Application Programming Interface createTodo(message) deleteTodo(todoid) editTodo(todoid, message, ...)
  • 40. URL: Universal Resource Locator /todos /todos/<id> /todos?todoid=<id> /todos?maxPages=<num> https://my-domain.api.com
  • 41. HTTP: Hypertext Transfer Protocol /todos/<id> [GET] /todos/<id> [DEL] /todos?todoid=<id> [GET] /todos?maxPages=<num> https://my-domain.api.com
  • 42. 200 OK: The response has succeeded! 201 Created: The request has succeeded, and the resource has been created (usually for POST) 400 Bad Request: The server could not understand the request due to invalid syntax 401 Unauthorized: The client is not allowed to get the requested response 404 Not Found: The server cannot find the requested resource 418 IĘźm a teapot: The server refuses to brew coffee because it is, permanently, a teapot. 500 Internal Server Error: The server has encountered an issue while processing your request after issuing an http request, we expect to receive a status code and response body (typically JSON). http statuses describe what the server did in response to the request.
  • 43. api integration connecting our frontend to our backend