SlideShare a Scribd company logo
React
Introduction to React
By Angela Lehru
@LehruAJay
What is React
A Javascript library for building user interfaces like web applications.
React can be used as a base in the development of single-page applications.
Create and Render a React Element
const element = React.createElement(
'h1',
{
id: 'main-title',
title: 'This is a title'
},
'Hello World'
)
ReactDOM.render(element, document.getElementById('root'));
React Dom
A library that lets React connect to and update the DOM
JSX
A syntax extension to Javascript that is used with React to describe elements in
the UI. As we’ll see, it resembles writing HTML.
We need Babel to transpile JSX into Javascript to be rendered on the browser. Try
it out babeljs.io/repl
To add Babel in a project:
<html/><head/> - <script src="https://unpkg.com/babel-
standalone@6.15.0/babel.min.js"></script>
<html/><head/> - <script type="text/babel" src="app.js"></script>
Set up a development server
Install http-server
1. npm init -y
2. npm i -S http-server
Add a start script to the package.json
"scripts": {
"start": "http-server"
},
Create React Project
create-react-app is an abstract way of getting started on a React Project. It
configures:
- Development server
- Webpack
- Babel
To install via command line/terminal:
npx create-react-app project-name
Let’s build an Inventory App
Components
Components
A typical functional component
import React, { Component, Fragment} from 'react';
const HelloWorld () {
return (
<h1>Hello World</h1>
);
}
export default HelloWorld;
State
A class component
import React, { Component, Fragment} from 'react';
class MainBody extends Component {
state = {
value:0
}
formatCount() {
return this.state.value === 0 ? 'Zero' : this.state.value
}
render() {
return (
<Fragment>
<span>{this.formatCount()}</span>
...
</Fragment>
);
}
}
export default MainBody;
Handling events
import React, { Component, Fragment} from 'react';
class MainBody extends Component {
state = {
count:0
}
handleIncrement () {
console.log(‘Add clicked’)
}
render() {
return (
<Fragment>
<button onClick={this.handleIncrement}>Add</button>
...
</Fragment>
);
}
export default MainBody;
Updating state
this.setState({ value: state})
import React, { Component, Fragment} from 'react';
class MainBody extends Component {
state = {
value:0
}
handleIncrement = () => {
console.log(‘Add clicked’, this.state.value)
}
render() {
return (
<Fragment>
<button onClick={this.handleIncrement}>Add</button>
...
</Fragment>
);
}
export default MainBody;
Parent - Child Components
import React, { Component, Fragment} from 'react';
class Items extends Component {
render() {
return (
<Fragment>
<Item />
<Item />
<Item />
</Fragment>
);
}
export default MainBody;
Rendering Lists
import React, { Component, Fragment} from 'react';
class MainBody extends Component {
state = {
tags: [tag1, tag2, tag3]
}
render() {
return (
<Fragment>
<ul>{this.state.tags.map(tag => <li key={tag}>{tag}</li>}</ul>
...
</Fragment>
);
}
export default MainBody;
Parent - Child Components
import React, { Component, Fragment} from 'react';
import MainBody from './components/mainBody';
class Items extends Component {
state = {
items: [
{ id: 1, value: 1 }
}
render() {
return (
<Fragment>
{this.state.items.map(item =>
<MainBody key={item.id} value={item.value}></MainBody>)}
</Fragment>
);
}
export default Items;
Passing Data to components(props)
import React, { Component, Fragment} from 'react';
class MainBody extends Component {
state = {
value:this.props.value
}
render() {
return (
<Fragment>
...
</Fragment>
);
}
export default Items;
Passing Children
Special prop called children, we use when we want to pass something between
the opening and closing tags of an element
1. Pass element in the component
2. Pass{this.props.children}in the parent component
<MainBody><h4>Item #{counter.id}</h4></MainBody>
React Tree
Props Vs State
Stateless Functional Components
Resources
Link to source code - Github repo
References used:
https://www.youtube.com/watch?v=Ke90Tje7VS0
https://reactjs.org/docs/
Questions

More Related Content

What's hot (20)

PDF
Switch to React.js from AngularJS developer
Eugene Zharkov
 
PPTX
React with Redux
Stanimir Todorov
 
PDF
Intro to Redux | DreamLab Academy #3
DreamLab
 
PPTX
Better web apps with React and Redux
Ali Sa'o
 
PPTX
ReactJs presentation
nishasowdri
 
PPTX
React и redux
Дмитрий Радыно
 
PPTX
React & redux
Cédric Hartland
 
PDF
React for Dummies
Mitch Chen
 
PDF
Creating a WYSIWYG Editor with React
peychevi
 
PDF
React redux
Michel Perez
 
PDF
React.js and Redux overview
Alex Bachuk
 
PDF
Intro to ReactJS
Harvard Web Working Group
 
PDF
Introduction to React & Redux
Boris Dinkevich
 
PPTX
React render props
Saikat Samanta
 
PDF
React and redux
Mystic Coders, LLC
 
PDF
Quick start with React | DreamLab Academy #2
DreamLab
 
PDF
React, Redux, ES2015 by Max Petruck
Maksym Petruk
 
PDF
Redux vs Alt
Uldis Sturms
 
PPTX
Introduction to React JS for beginners
Varun Raj
 
PDF
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 
Switch to React.js from AngularJS developer
Eugene Zharkov
 
React with Redux
Stanimir Todorov
 
Intro to Redux | DreamLab Academy #3
DreamLab
 
Better web apps with React and Redux
Ali Sa'o
 
ReactJs presentation
nishasowdri
 
React & redux
Cédric Hartland
 
React for Dummies
Mitch Chen
 
Creating a WYSIWYG Editor with React
peychevi
 
React redux
Michel Perez
 
React.js and Redux overview
Alex Bachuk
 
Intro to ReactJS
Harvard Web Working Group
 
Introduction to React & Redux
Boris Dinkevich
 
React render props
Saikat Samanta
 
React and redux
Mystic Coders, LLC
 
Quick start with React | DreamLab Academy #2
DreamLab
 
React, Redux, ES2015 by Max Petruck
Maksym Petruk
 
Redux vs Alt
Uldis Sturms
 
Introduction to React JS for beginners
Varun Raj
 
Workshop 20: ReactJS Part II Flux Pattern & Redux
Visual Engineering
 

Similar to React outbox (20)

PPTX
React & Redux for noobs
[T]echdencias
 
PPTX
Getting Started with React v16
Benny Neugebauer
 
PDF
Manage the Flux of your Web Application: Let's Redux
Commit University
 
PDF
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
PDF
Server side rendering with React and Symfony
Ignacio Martín
 
PDF
Introduction to React for Frontend Developers
Sergio Nakamura
 
PPTX
Introduction to React and MobX
Anjali Chawla
 
PDF
Building Universal Web Apps with React ForwardJS 2017
Elyse Kolker Gordon
 
PPTX
ReactJS
Ram Murat Sharma
 
PDF
React lecture
Christoffer Noring
 
PPTX
Build web apps with react js
dhanushkacnd
 
PDF
Reactивная тяга
Vitebsk Miniq
 
PPTX
Intro react js
Vijayakanth MP
 
PDF
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
 
PDF
React js
Rajesh Kolla
 
PDF
Intro to React | DreamLab Academy
DreamLab
 
PDF
React 101
Casear Chu
 
PPTX
Let's react - Meetup
RAJNISH KATHAROTIYA
 
PDF
Stay with React.js in 2020
Jerry Liao
 
PDF
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
 
React & Redux for noobs
[T]echdencias
 
Getting Started with React v16
Benny Neugebauer
 
Manage the Flux of your Web Application: Let's Redux
Commit University
 
Universal JS Web Applications with React - Web Summer Camp 2017, Rovinj (Work...
Luciano Mammino
 
Server side rendering with React and Symfony
Ignacio Martín
 
Introduction to React for Frontend Developers
Sergio Nakamura
 
Introduction to React and MobX
Anjali Chawla
 
Building Universal Web Apps with React ForwardJS 2017
Elyse Kolker Gordon
 
React lecture
Christoffer Noring
 
Build web apps with react js
dhanushkacnd
 
Reactивная тяга
Vitebsk Miniq
 
Intro react js
Vijayakanth MP
 
EWD 3 Training Course Part 38: Building a React.js application with QEWD, Part 4
Rob Tweed
 
React js
Rajesh Kolla
 
Intro to React | DreamLab Academy
DreamLab
 
React 101
Casear Chu
 
Let's react - Meetup
RAJNISH KATHAROTIYA
 
Stay with React.js in 2020
Jerry Liao
 
EWD 3 Training Course Part 39: Building a React.js application with QEWD, Part 3
Rob Tweed
 
Ad

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Ad

React outbox

  • 1. React Introduction to React By Angela Lehru @LehruAJay
  • 2. What is React A Javascript library for building user interfaces like web applications. React can be used as a base in the development of single-page applications.
  • 3. Create and Render a React Element const element = React.createElement( 'h1', { id: 'main-title', title: 'This is a title' }, 'Hello World' ) ReactDOM.render(element, document.getElementById('root'));
  • 4. React Dom A library that lets React connect to and update the DOM
  • 5. JSX A syntax extension to Javascript that is used with React to describe elements in the UI. As we’ll see, it resembles writing HTML. We need Babel to transpile JSX into Javascript to be rendered on the browser. Try it out babeljs.io/repl To add Babel in a project: <html/><head/> - <script src="https://unpkg.com/babel- [email protected]/babel.min.js"></script> <html/><head/> - <script type="text/babel" src="app.js"></script>
  • 6. Set up a development server Install http-server 1. npm init -y 2. npm i -S http-server Add a start script to the package.json "scripts": { "start": "http-server" },
  • 7. Create React Project create-react-app is an abstract way of getting started on a React Project. It configures: - Development server - Webpack - Babel To install via command line/terminal: npx create-react-app project-name
  • 8. Let’s build an Inventory App
  • 10. Components A typical functional component import React, { Component, Fragment} from 'react'; const HelloWorld () { return ( <h1>Hello World</h1> ); } export default HelloWorld;
  • 11. State A class component import React, { Component, Fragment} from 'react'; class MainBody extends Component { state = { value:0 } formatCount() { return this.state.value === 0 ? 'Zero' : this.state.value } render() { return ( <Fragment> <span>{this.formatCount()}</span> ... </Fragment> ); } } export default MainBody;
  • 12. Handling events import React, { Component, Fragment} from 'react'; class MainBody extends Component { state = { count:0 } handleIncrement () { console.log(‘Add clicked’) } render() { return ( <Fragment> <button onClick={this.handleIncrement}>Add</button> ... </Fragment> ); } export default MainBody;
  • 13. Updating state this.setState({ value: state}) import React, { Component, Fragment} from 'react'; class MainBody extends Component { state = { value:0 } handleIncrement = () => { console.log(‘Add clicked’, this.state.value) } render() { return ( <Fragment> <button onClick={this.handleIncrement}>Add</button> ... </Fragment> ); } export default MainBody;
  • 14. Parent - Child Components import React, { Component, Fragment} from 'react'; class Items extends Component { render() { return ( <Fragment> <Item /> <Item /> <Item /> </Fragment> ); } export default MainBody;
  • 15. Rendering Lists import React, { Component, Fragment} from 'react'; class MainBody extends Component { state = { tags: [tag1, tag2, tag3] } render() { return ( <Fragment> <ul>{this.state.tags.map(tag => <li key={tag}>{tag}</li>}</ul> ... </Fragment> ); } export default MainBody;
  • 16. Parent - Child Components import React, { Component, Fragment} from 'react'; import MainBody from './components/mainBody'; class Items extends Component { state = { items: [ { id: 1, value: 1 } } render() { return ( <Fragment> {this.state.items.map(item => <MainBody key={item.id} value={item.value}></MainBody>)} </Fragment> ); } export default Items;
  • 17. Passing Data to components(props) import React, { Component, Fragment} from 'react'; class MainBody extends Component { state = { value:this.props.value } render() { return ( <Fragment> ... </Fragment> ); } export default Items;
  • 18. Passing Children Special prop called children, we use when we want to pass something between the opening and closing tags of an element 1. Pass element in the component 2. Pass{this.props.children}in the parent component <MainBody><h4>Item #{counter.id}</h4></MainBody>
  • 22. Resources Link to source code - Github repo References used: https://www.youtube.com/watch?v=Ke90Tje7VS0 https://reactjs.org/docs/

Editor's Notes

  • #3: A single-page application (SPA) is a web application or web site that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server. This approach avoids interruption of the user experience between successive pages.
  • #4: Add react to a website https://reactjs.org/docs/add-react-to-a-website.html
  • #5: The createElement() method creates and returns a React element of the given type React doesn’t create actual DOM nodes. React creates objects that describe DOM nodes The ReactDOM.render() method renders React elements to the DOM React doesn’t manipulate and update the DOM directly. React only manages what gets rendered to the DOM via ReactDOM.render(). It’s the job of render() to interpret the element objects and create DOM nodes out of them.
  • #8: Webpack for bundling our files Babel for compiling our JSX into javascript
  • #11: Create Navbar and render it in App.js
  • #14: Arrow functions -> to access this.state.value Update state -> this.setState({ value: this.state.value + 1 })
  • #15: {this.state.counters.map(counter => <MainBody key={counter.id} value={counter.value}> <h4>Item #{counter.id}</h4> </MainBody>)}