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?
Full Stack React Workshop [CSSC x GDSC]
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

PPTX
reactJS
PDF
An introduction to React.js
PPTX
Introduction to React JS for beginners
PPTX
React + Redux Introduction
PPTX
React - Start learning today
PPTX
React js programming concept
PDF
Basics of React Hooks.pptx.pdf
PPTX
Its time to React.js
reactJS
An introduction to React.js
Introduction to React JS for beginners
React + Redux Introduction
React - Start learning today
React js programming concept
Basics of React Hooks.pptx.pdf
Its time to React.js

What's hot (20)

ODP
Introduction to ReactJS
PDF
React JS - Introduction
PDF
React js
PPTX
React workshop
PDF
PDF
React and redux
PDF
React JS & Functional Programming Principles
PPTX
Introduction to React
PPTX
PDF
Introduction to React JS
PPTX
Introduction to React JS for beginners | Namespace IT
PDF
Workshop 21: React Router
PPTX
React JS: A Secret Preview
PPTX
React hooks
PPTX
Introduction to react_js
PPTX
React js - The Core Concepts
PDF
React Js Simplified
PPTX
React web development
PPTX
React hooks
Introduction to ReactJS
React JS - Introduction
React js
React workshop
React and redux
React JS & Functional Programming Principles
Introduction to React
Introduction to React JS
Introduction to React JS for beginners | Namespace IT
Workshop 21: React Router
React JS: A Secret Preview
React hooks
Introduction to react_js
React js - The Core Concepts
React Js Simplified
React web development
React hooks
Ad

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

PPTX
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
PPTX
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
PPTX
React for JavaScipt Introduction and functions
PPTX
reacts js with basic details Detailed_ReactJS_Presentation.pptx
PDF
react hook and wesite making structure ppt
PDF
Fundamental concepts of react js
PDF
REACTJS.pdf
PPTX
Reactjs notes.pptx for web development- tutorial and theory
PDF
Welcome to React & Flux !
PPT
PPTX
[Final] ReactJS presentation
PDF
Learn react by Etietop Demas
PPTX
React_Complete.pptx
PPTX
Fullstack JS Workshop
PPTX
React Workshop: Core concepts of react
PPTX
React JS Workings Exercises Extra Classes
PPTX
PPTX
Presentation on "An Introduction to ReactJS"
PPTX
React & Redux for noobs
PPTX
ReactJS (1)
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
unit 2 React js.pptxdgdgdgdgdgdgdgdgdsgdgdg
React for JavaScipt Introduction and functions
reacts js with basic details Detailed_ReactJS_Presentation.pptx
react hook and wesite making structure ppt
Fundamental concepts of react js
REACTJS.pdf
Reactjs notes.pptx for web development- tutorial and theory
Welcome to React & Flux !
[Final] ReactJS presentation
Learn react by Etietop Demas
React_Complete.pptx
Fullstack JS Workshop
React Workshop: Core concepts of react
React JS Workings Exercises Extra Classes
Presentation on "An Introduction to ReactJS"
React & Redux for noobs
ReactJS (1)
Ad

More from GDSC UofT Mississauga (20)

PDF
CSSC ML Workshop
PPTX
ICCIT Council × GDSC: UX / UI and Figma
PDF
Community Projects Info Session Fall 2023
PDF
GDSC x Deerhacks - Origami Workshop
PDF
Reverse Engineering 101
PDF
Michael's OWASP Juice Shop Workshop
PDF
MCSS × GDSC: Intro to Cybersecurity Workshop
PDF
PDF
Discord Bot Workshop Slides
PDF
Web Scraping Workshop
PDF
Devops Workshop
PDF
HTML_CSS_JS Workshop
PDF
DevOps Workshop Part 1
PDF
Docker workshop GDSC_CSSC
PDF
Back-end (Flask_AWS)
PDF
Git Init (Introduction to Git)
PPTX
Database Workshop Slides
PPTX
ChatGPT General Meeting
PPTX
Elon & Twitter General Meeting
CSSC ML Workshop
ICCIT Council × GDSC: UX / UI and Figma
Community Projects Info Session Fall 2023
GDSC x Deerhacks - Origami Workshop
Reverse Engineering 101
Michael's OWASP Juice Shop Workshop
MCSS × GDSC: Intro to Cybersecurity Workshop
Discord Bot Workshop Slides
Web Scraping Workshop
Devops Workshop
HTML_CSS_JS Workshop
DevOps Workshop Part 1
Docker workshop GDSC_CSSC
Back-end (Flask_AWS)
Git Init (Introduction to Git)
Database Workshop Slides
ChatGPT General Meeting
Elon & Twitter General Meeting

Recently uploaded (20)

PPTX
Blending method and technology for hydrogen.pptx
PDF
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
PPT
Overviiew on Intellectual property right
PDF
Domain-specific knowledge and context in large language models: challenges, c...
PPTX
Information-Technology-in-Human-Society (2).pptx
PDF
substrate PowerPoint Presentation basic one
PDF
Intravenous drug administration application for pediatric patients via augmen...
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PPTX
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
PPTX
How to use fields_get method in Odoo 18
PPTX
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
PPTX
Information-Technology-in-Human-Society.pptx
PDF
Secure Java Applications against Quantum Threats
PDF
Applying Agentic AI in Enterprise Automation
PPTX
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
PDF
Introduction to c language from lecture slides
PDF
Human Computer Interaction Miterm Lesson
PPTX
Presentation - Principles of Instructional Design.pptx
PDF
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
PDF
Revolutionizing recommendations a survey: a comprehensive exploration of mode...
Blending method and technology for hydrogen.pptx
ELLIE29.pdfWETWETAWTAWETAETAETERTRTERTER
Overviiew on Intellectual property right
Domain-specific knowledge and context in large language models: challenges, c...
Information-Technology-in-Human-Society (2).pptx
substrate PowerPoint Presentation basic one
Intravenous drug administration application for pediatric patients via augmen...
Report in SIP_Distance_Learning_Technology_Impact.pptx
Rise of the Digital Control Grid Zeee Media and Hope and Tivon FTWProject.com
How to use fields_get method in Odoo 18
From XAI to XEE through Influence and Provenance.Controlling model fairness o...
Information-Technology-in-Human-Society.pptx
Secure Java Applications against Quantum Threats
Applying Agentic AI in Enterprise Automation
From Curiosity to ROI — Cost-Benefit Analysis of Agentic Automation [3/6]
Introduction to c language from lecture slides
Human Computer Interaction Miterm Lesson
Presentation - Principles of Instructional Design.pptx
FASHION-DRIVEN TEXTILES AS A CRYSTAL OF A NEW STREAM FOR STAKEHOLDER CAPITALI...
Revolutionizing recommendations a survey: a comprehensive exploration of mode...

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?
  • 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