SlideShare una empresa de Scribd logo
1 de 39
Descargar para leer sin conexión
React For Dummies
Mitch Chen
Agenda
▸ Components
▸ JSX
▸ Virtual DOM
▸ Rendering
▸ State and Props
▸ Component Lifecycle
▸ Hands-on
▸ Where to go from here
▸ Q & A
Components
▸ Separation of Concerns: Reduce Coupling, increase
Cohesion
▸ Display Logic and Markup are highly Cohesive: They both
show the UI
▸ Components are the right way to separate concerns
▸ Components are Reusable, Composable and Unit Testable
Components
▸ React Components use Expressive power of programming
language(JSX) to build UIs
▸ React Components: A highly Cohesive building block for
UIs Loosely Coupled with other components
▸ React makes you build many simple components that does
one thing really well
Components - Syntax
▸ ES5 Syntax
var	
  MyApp	
  =	
  React.createClass({…});
Components - Syntax
▸ ES6 Syntax
class	
  MyApp	
  extends	
  React.Component	
  {…}
Practice
Hello, world!
http://goo.gl/c7pGK9
Components - Syntax
▸ Stateless Component
These components must not retain internal state,
do not have the component lifecycle methods.
Components - Syntax
▸ Stateless Component - ES5
func.on	
  MyApp(props)	
  {	
  
	
  	
  	
  	
  return	
  <h2>Hello,	
  {props.name}</h2>;	
  
}	
  
ReactDOM.render(	
  
	
  	
  	
  	
  <MyApp	
  name=“Mitch”	
  />,	
  document.getElementById(‘root’)	
  
);
Components - Syntax
▸ Stateless Component - ES6
const	
  MyApp	
  =	
  (props)	
  =>	
  <h2>Hello,	
  {props.name}</h2>;	
  
ReactDOM.render(	
  
	
  	
  	
  	
  <MyApp	
  name=“Mitch”	
  />,	
  document.getElementById(‘root’)	
  
);
JSX
JSX is a JavaScript syntax extension
that looks similar to XML.
JSX
Pure	
  JavaScript:	
  
React.createElement(‘a’,	
  {href:	
  ‘hPps://facebook.github.io/
react/'},	
  ‘Hello!’);	
  
JSX	
  Syntax:	
  
<a	
  href=“hPps://facebook.github.io/react/“>Hello!</a>
JSX
▸ Supported HTML Elements
a abbr address area article aside audio b base bdi bdo big blockquote body br
button canvas caption cite code col colgroup data datalist dd del details dfn
dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5
h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li
link main map mark menu menuitem meta meter nav noscript object ol optgroup
option output p param picture pre progress q rp rt ruby s samp script section
select small source span strong style sub summary sup table tbody td textarea
tfoot th thead time title tr track u ul var video wbr
JSX
▸ Supported HTML Attributes
accept acceptCharset accessKey action allowFullScreen allowTransparency alt
async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge
charSet checked cite classID className colSpan cols content contentEditable
contextMenu controls coords crossOrigin data dateTime default defer dir
disabled download draggable encType form formAction formEncType formMethod
formNoValidate formTarget frameBorder headers height hidden high href hrefLang
htmlFor httpEquiv icon id inputMode integrity is keyParams keyType kind label
lang list loop low manifest marginHeight marginWidth max maxLength media
mediaGroup method min minLength multiple muted name noValidate nonce open
optimum pattern placeholder poster preload profile radioGroup readOnly rel
required reversed role rowSpan rows sandbox scope scoped scrolling seamless
selected shape size sizes span spellCheck src srcDoc srcLang srcSet start step
style summary tabIndex target title type useMap value width wmode wrap
JSX
▸ Event System
▸ DOM Differences
▸ Special Non-DOM Attributes
Virtual Dom
▸ Makes re-rendering on every change fast
▸ Computes minimal DOM operations
▸ Batched reads and writes for optimal DOM performance
▸ Usually faster than manual DOM operations
▸ 60fps, even in a UIWebView on the iPhone
Virtual Dom
A ReactElement is a light, stateless, immutable,
virtual representation of a DOM Element. It is
a virtual DOM
Rendering
▸ State has data you own, Props has data you borrow
▸ When the State(data) changes, React Re-renders the Entire
Component
▸ No magical data binding
▸ No model dirty checking
▸ No more explicit DOM operations: Everything is
declarative
Rendering
setState Dirty
Batching
Rendering
Dirty
Sub-tree Rendering
Re-Rendered
State And Props
▸ State is mutable
▸ State is private to the component
▸ State can be changed by calling this.setState()
▸ When the state updates, the component re-renders itself
State And Props
▸ Props are immutable
▸ Based on its props, each component has rendered itself
once
▸ Props are passed from the parent
▸ Props are owned by the parent
State And Props
▸ Prop Validation
class	
  MyApp	
  extends	
  React.Component	
  {…}	
  
MyApp.propTypes	
  =	
  {	
  
	
  	
  	
  	
  opVonalArray:	
  React.PropTypes.array,	
  
	
  	
  	
  	
  opVonalBool:	
  React.PropTypes.bool,	
  
	
  	
  	
  	
  opVonalFunc:	
  React.PropTypes.func,	
  
	
  	
  	
  	
  opVonalNumber:	
  React.PropTypes.number,	
  
	
  	
  	
  	
  opVonalObject:	
  React.PropTypes.object,	
  
	
  	
  	
  	
  opVonalString:	
  React.PropTypes.string,	
  
	
  	
  	
  	
  opVonalNode:	
  React.PropTypes.node,	
  
	
  	
  	
  	
  opVonalElement:	
  React.PropTypes.element	
  
};
State And Props
▸ Prop Validation
class	
  MyApp	
  extends	
  React.Component	
  {…}	
  
MyApp.propTypes	
  =	
  {	
  
	
  	
  	
  	
  opVonalMessage:	
  React.PropTypes.instanceOf(Message),	
  
	
  	
  	
  	
  opVonalEnum:	
  React.PropTypes.oneOf([‘News’,	
  ‘Photos’]),	
  
	
  	
  	
  	
  opVonalUnion:	
  React.PropTypes.oneOfType([	
  
	
  	
  	
  	
  	
  	
  	
  	
  React.PropTypes.number,	
  
	
  	
  	
  	
  	
  	
  	
  	
  React.PropTypes.string	
  
	
  	
  	
  	
  ]),	
  
	
  	
  	
  	
  opVonalArrayOf:	
  React.PropTypes.arrayOf(React.PropTypes.number),	
  
	
  	
  	
  	
  opVonalObjectOf:	
  React.PropTypes.objectOf(React.PropTypes.number)	
  
};
State And Props
▸ Prop Validation
class	
  MyApp	
  extends	
  React.Component	
  {…}	
  
MyApp.propTypes	
  =	
  {	
  
	
  	
  	
  	
  opVonalObjectWithShape:	
  React.PropTypes.shape({	
  
	
  	
  	
  	
  	
  	
  	
  	
  name:	
  React.PropTypes.string,	
  
	
  	
  	
  	
  	
  	
  	
  	
  count:	
  React.PropTypes.number	
  
	
  	
  	
  	
  }),	
  
	
  	
  	
  	
  requiredFunc:	
  React.PropTypes.func.isRequired,	
  
	
  	
  	
  	
  requiredAny:	
  React.PropTypes.any.isRequired	
  
};
State And Props
▸ Dumb Components
- The most reusable components available
- They have a know-nothing approach to the
application in which they are used.
- It does not connect to any Flux interfaces, and is
passed the exact data it needs to render (via Props).
Practice
NavBar Component
http://codepen.io/mitchbox/pen/
ZOAWqk
Practice
ProfileCard Component
http://codepen.io/mitchbox/pen/
GqQkwE
State And Props
▸ Smart Components
- Less reusable outside a single application or set of
applications
- They are aware of application-level state.
- It may bind to Flux actions or stores in order to
directly integrate with business logic and react to
changes.
Practice
Click and count
http://codepen.io/mitchbox/pen/
mEXPaw
▸ Changing props and state
State And Props
- Props State
Can get initial value from parent Component? Y Y
Can be changed by parent Component? Y N
Can set default values inside Component? Y Y
Can change inside Component? N Y
Can set initial value for child Components? Y Y
Can change in child Components? Y N
Component Lifecycle Methods
▸ componentWillMount
▸ componentDidMount
▸ componentWillReceiveProps
▸ componentWillUnmount
▸ shouldComponentUpdate
▸ componentWillUpdate
▸ componentDidUpdate
▸ Search Github User (Integrate with Github API)
Hands-On
Github API
https://api.github.com/users/{username}
▸ Search Github User (Integrate with Github API)
Hands-On
- Include NavBar and ProfileCard components
- Implement API helper function
- Create an App Container Component
- Add event handler and call Github API
- State management
- UI Rendering with state
- http://codepen.io/mitchbox/pen/bZLpOr
Where To Go From Here
▸ Development Environment & Tools
▸ Basic Technical Skill Requirements
▸ Familiar with React Related Third Party Libraries
▸ Familiar with Migo Internal Libraries and Boilerplate
Where To Go From Here
▸ Development Environment & Tools
- Node.js / NPM
- Webpack / Gulp / Grunt
- Babel (JavaScript Compiler)
- Live Reload
- ESLint
- Mocha / Chai
Where To Go From Here
▸ Basic Technical Skill Requirements
- CSS / CSS 3 / SASS / (PostCSS)
- Naming Convention for CSS (BEM)
- Coding Convention for React
- ECMAScript 2015 aka ES6
- Functional Programming
Where To Go From Here
▸ Familiar with React Related Third Party Libraries
- Flux
- ReFlux
- Redux
- Redux Thunk
- Redux Middleware
- React-router
- Classnames
- Immutable.js
- Flow
Q & A

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
ReactJS
ReactJSReactJS
ReactJS
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
React state
React  stateReact  state
React state
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
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
 
React js
React jsReact js
React js
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
reactJS
reactJSreactJS
reactJS
 
Introduction to react_js
Introduction to react_jsIntroduction to react_js
Introduction to react_js
 
ReactJs
ReactJsReactJs
ReactJs
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
Understanding react hooks
Understanding react hooksUnderstanding react hooks
Understanding react hooks
 
React Context API
React Context APIReact Context API
React Context API
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
React hooks
React hooksReact hooks
React hooks
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 

Destacado

A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.jsDoug Neiner
 
React.js for Back-End developers
React.js for Back-End developersReact.js for Back-End developers
React.js for Back-End developersArtyom Trityak
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSHoang Long
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps. Emanuele DelBono
 
React in Native Apps - Meetup React - 20150409
React in Native Apps - Meetup React - 20150409React in Native Apps - Meetup React - 20150409
React in Native Apps - Meetup React - 20150409Minko3D
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#Sagar Pednekar
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)jeffz
 
Engine de template em Javascript com HTML Sprites
Engine de template em Javascript com HTML SpritesEngine de template em Javascript com HTML Sprites
Engine de template em Javascript com HTML SpritesMilfont Consulting
 

Destacado (13)

React js
React jsReact js
React js
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
Redis tutoring
Redis tutoringRedis tutoring
Redis tutoring
 
React-js
React-jsReact-js
React-js
 
React.js
React.jsReact.js
React.js
 
React.js for Back-End developers
React.js for Back-End developersReact.js for Back-End developers
React.js for Back-End developers
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Reactjs
Reactjs Reactjs
Reactjs
 
React.js in real world apps.
React.js in real world apps. React.js in real world apps.
React.js in real world apps.
 
React in Native Apps - Meetup React - 20150409
React in Native Apps - Meetup React - 20150409React in Native Apps - Meetup React - 20150409
React in Native Apps - Meetup React - 20150409
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)Why Java Sucks and C# Rocks (Final)
Why Java Sucks and C# Rocks (Final)
 
Engine de template em Javascript com HTML Sprites
Engine de template em Javascript com HTML SpritesEngine de template em Javascript com HTML Sprites
Engine de template em Javascript com HTML Sprites
 

Similar a React for Dummies

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 applicationsJeff Durta
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfStephieJohn
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react jsStephieJohn
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with ReactNetcetera
 
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 applicationsJeff Durta
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
 
Introduction to React JS for beginners
Introduction to React JS for beginners Introduction to React JS for beginners
Introduction to React JS for beginners Varun Raj
 
React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥Remo Jansen
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to JavaSMIJava
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionVisual Engineering
 
Purifying React (with annotations)
Purifying React (with annotations)Purifying React (with annotations)
Purifying React (with annotations)Robin Pokorny
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - Reactrbl002
 
A React Journey
A React JourneyA React Journey
A React JourneyLinkMe Srl
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)tuanpa206
 

Similar a React for Dummies (20)

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
 
Fundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdfFundamental Concepts of React JS for Beginners.pdf
Fundamental Concepts of React JS for Beginners.pdf
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Content-Driven Apps with React
Content-Driven Apps with ReactContent-Driven Apps with React
Content-Driven Apps with React
 
Lec7Handout.ppt
Lec7Handout.pptLec7Handout.ppt
Lec7Handout.ppt
 
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 - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
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 + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥React + Redux + TypeScript === ♥
React + Redux + TypeScript === ♥
 
SMI - Introduction to Java
SMI - Introduction to JavaSMI - Introduction to Java
SMI - Introduction to Java
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Workshop 19: ReactJS Introduction
Workshop 19: ReactJS IntroductionWorkshop 19: ReactJS Introduction
Workshop 19: ReactJS Introduction
 
Purifying React (with annotations)
Purifying React (with annotations)Purifying React (with annotations)
Purifying React (with annotations)
 
React native
React nativeReact native
React native
 
ReactJS (1)
ReactJS (1)ReactJS (1)
ReactJS (1)
 
OttawaJS - React
OttawaJS - ReactOttawaJS - React
OttawaJS - React
 
A React Journey
A React JourneyA React Journey
A React Journey
 
React, Flux and more (p1)
React, Flux and more (p1)React, Flux and more (p1)
React, Flux and more (p1)
 
React
ReactReact
React
 

Último

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 

Último (20)

Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 

React for Dummies

  • 2. Agenda ▸ Components ▸ JSX ▸ Virtual DOM ▸ Rendering ▸ State and Props ▸ Component Lifecycle ▸ Hands-on ▸ Where to go from here ▸ Q & A
  • 3. Components ▸ Separation of Concerns: Reduce Coupling, increase Cohesion ▸ Display Logic and Markup are highly Cohesive: They both show the UI ▸ Components are the right way to separate concerns ▸ Components are Reusable, Composable and Unit Testable
  • 4. Components ▸ React Components use Expressive power of programming language(JSX) to build UIs ▸ React Components: A highly Cohesive building block for UIs Loosely Coupled with other components ▸ React makes you build many simple components that does one thing really well
  • 5. Components - Syntax ▸ ES5 Syntax var  MyApp  =  React.createClass({…});
  • 6. Components - Syntax ▸ ES6 Syntax class  MyApp  extends  React.Component  {…}
  • 8. Components - Syntax ▸ Stateless Component These components must not retain internal state, do not have the component lifecycle methods.
  • 9. Components - Syntax ▸ Stateless Component - ES5 func.on  MyApp(props)  {          return  <h2>Hello,  {props.name}</h2>;   }   ReactDOM.render(          <MyApp  name=“Mitch”  />,  document.getElementById(‘root’)   );
  • 10. Components - Syntax ▸ Stateless Component - ES6 const  MyApp  =  (props)  =>  <h2>Hello,  {props.name}</h2>;   ReactDOM.render(          <MyApp  name=“Mitch”  />,  document.getElementById(‘root’)   );
  • 11. JSX JSX is a JavaScript syntax extension that looks similar to XML.
  • 12. JSX Pure  JavaScript:   React.createElement(‘a’,  {href:  ‘hPps://facebook.github.io/ react/'},  ‘Hello!’);   JSX  Syntax:   <a  href=“hPps://facebook.github.io/react/“>Hello!</a>
  • 13. JSX ▸ Supported HTML Elements a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn dialog div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hgroup hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param picture pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr
  • 14. JSX ▸ Supported HTML Attributes accept acceptCharset accessKey action allowFullScreen allowTransparency alt async autoComplete autoFocus autoPlay capture cellPadding cellSpacing challenge charSet checked cite classID className colSpan cols content contentEditable contextMenu controls coords crossOrigin data dateTime default defer dir disabled download draggable encType form formAction formEncType formMethod formNoValidate formTarget frameBorder headers height hidden high href hrefLang htmlFor httpEquiv icon id inputMode integrity is keyParams keyType kind label lang list loop low manifest marginHeight marginWidth max maxLength media mediaGroup method min minLength multiple muted name noValidate nonce open optimum pattern placeholder poster preload profile radioGroup readOnly rel required reversed role rowSpan rows sandbox scope scoped scrolling seamless selected shape size sizes span spellCheck src srcDoc srcLang srcSet start step style summary tabIndex target title type useMap value width wmode wrap
  • 15. JSX ▸ Event System ▸ DOM Differences ▸ Special Non-DOM Attributes
  • 16. Virtual Dom ▸ Makes re-rendering on every change fast ▸ Computes minimal DOM operations ▸ Batched reads and writes for optimal DOM performance ▸ Usually faster than manual DOM operations ▸ 60fps, even in a UIWebView on the iPhone
  • 17. Virtual Dom A ReactElement is a light, stateless, immutable, virtual representation of a DOM Element. It is a virtual DOM
  • 18. Rendering ▸ State has data you own, Props has data you borrow ▸ When the State(data) changes, React Re-renders the Entire Component ▸ No magical data binding ▸ No model dirty checking ▸ No more explicit DOM operations: Everything is declarative
  • 21. State And Props ▸ State is mutable ▸ State is private to the component ▸ State can be changed by calling this.setState() ▸ When the state updates, the component re-renders itself
  • 22. State And Props ▸ Props are immutable ▸ Based on its props, each component has rendered itself once ▸ Props are passed from the parent ▸ Props are owned by the parent
  • 23. State And Props ▸ Prop Validation class  MyApp  extends  React.Component  {…}   MyApp.propTypes  =  {          opVonalArray:  React.PropTypes.array,          opVonalBool:  React.PropTypes.bool,          opVonalFunc:  React.PropTypes.func,          opVonalNumber:  React.PropTypes.number,          opVonalObject:  React.PropTypes.object,          opVonalString:  React.PropTypes.string,          opVonalNode:  React.PropTypes.node,          opVonalElement:  React.PropTypes.element   };
  • 24. State And Props ▸ Prop Validation class  MyApp  extends  React.Component  {…}   MyApp.propTypes  =  {          opVonalMessage:  React.PropTypes.instanceOf(Message),          opVonalEnum:  React.PropTypes.oneOf([‘News’,  ‘Photos’]),          opVonalUnion:  React.PropTypes.oneOfType([                  React.PropTypes.number,                  React.PropTypes.string          ]),          opVonalArrayOf:  React.PropTypes.arrayOf(React.PropTypes.number),          opVonalObjectOf:  React.PropTypes.objectOf(React.PropTypes.number)   };
  • 25. State And Props ▸ Prop Validation class  MyApp  extends  React.Component  {…}   MyApp.propTypes  =  {          opVonalObjectWithShape:  React.PropTypes.shape({                  name:  React.PropTypes.string,                  count:  React.PropTypes.number          }),          requiredFunc:  React.PropTypes.func.isRequired,          requiredAny:  React.PropTypes.any.isRequired   };
  • 26. State And Props ▸ Dumb Components - The most reusable components available - They have a know-nothing approach to the application in which they are used. - It does not connect to any Flux interfaces, and is passed the exact data it needs to render (via Props).
  • 29. State And Props ▸ Smart Components - Less reusable outside a single application or set of applications - They are aware of application-level state. - It may bind to Flux actions or stores in order to directly integrate with business logic and react to changes.
  • 31. ▸ Changing props and state State And Props - Props State Can get initial value from parent Component? Y Y Can be changed by parent Component? Y N Can set default values inside Component? Y Y Can change inside Component? N Y Can set initial value for child Components? Y Y Can change in child Components? Y N
  • 32. Component Lifecycle Methods ▸ componentWillMount ▸ componentDidMount ▸ componentWillReceiveProps ▸ componentWillUnmount ▸ shouldComponentUpdate ▸ componentWillUpdate ▸ componentDidUpdate
  • 33. ▸ Search Github User (Integrate with Github API) Hands-On Github API https://api.github.com/users/{username}
  • 34. ▸ Search Github User (Integrate with Github API) Hands-On - Include NavBar and ProfileCard components - Implement API helper function - Create an App Container Component - Add event handler and call Github API - State management - UI Rendering with state - http://codepen.io/mitchbox/pen/bZLpOr
  • 35. Where To Go From Here ▸ Development Environment & Tools ▸ Basic Technical Skill Requirements ▸ Familiar with React Related Third Party Libraries ▸ Familiar with Migo Internal Libraries and Boilerplate
  • 36. Where To Go From Here ▸ Development Environment & Tools - Node.js / NPM - Webpack / Gulp / Grunt - Babel (JavaScript Compiler) - Live Reload - ESLint - Mocha / Chai
  • 37. Where To Go From Here ▸ Basic Technical Skill Requirements - CSS / CSS 3 / SASS / (PostCSS) - Naming Convention for CSS (BEM) - Coding Convention for React - ECMAScript 2015 aka ES6 - Functional Programming
  • 38. Where To Go From Here ▸ Familiar with React Related Third Party Libraries - Flux - ReFlux - Redux - Redux Thunk - Redux Middleware - React-router - Classnames - Immutable.js - Flow
  • 39. Q & A