SlideShare a Scribd company logo
1 of 86
Download to read offline
©2015 T7
October 13, 2015
April 28, 2016
Getting Started
with React squaresconference.com
Slides:
j.mp/getting-started-react
GitHub repo:
github.com/t7/react-starter
Me, on Twitter:
@nathansmith
• Father of two rambunctious boys, who
are big fans of Star Wars and Legos.

• Self-taught. That just means I pestered
lots of people until I learned how to do
this stuff. Yet, I still doubt myself daily.

• I build the "legacy" software of tomorrow.

• I generally have a "get off my lawn"
attitude towards emerging technology.
Nathan Smith
Principal Front-End
Architect
Introduction
Scientific* comparison of "React.js" versus "Angular.js"
*Not really scientific.
Perhaps unsurprisingly, my off
the cuff, ill-informed reaction…
ended up being totally wrong.
(But, admitting when you're wrong
is part of being a grown-up, right?)
©2015 T7
Software development is a field
in which it is actually possible to
know less % overall, even if you
were to never forget anything.
There are always new things to
learn, because the total surface
area is continuously expanding.
Today, I would like to talk
to you about the "three Rs."
•Reading
•wRiting
•aRithmetic
There are three fundamental
aspects of most React apps.
•React = the "V" (and "C") layer.
•Redux = the "M" layer.
•Router = um, the "URL" layer? :)
PROOF POSITIVE OF COOL PROJECTS? LOGOS!
github.com/reactjs/react-routergithub.com/reactjs/reduxgithub.com/facebook/react
Actually, my projects are more like this.
Accounting.js Babel ECMAScript 6+ ESLint
Jest Lodash Markdown Moment.js
NPM PostCSS React ReactDOM
React Router React Test Utils Redux Sass (SCSS)
Sass-Lint Standard Webpack window.fetch
npm init -f && npm install --save-dev accounting autoprefixer
babel-core babel-jest babel-loader babel-plugin-transform-
runtime babel-preset-es2015 babel-preset-react babel-runtime
copy-webpack-plugin cross-env css-loader es6-promise eslint
eslint-config-standard eslint-config-standard-jsx eslint-
config-standard-react eslint-plugin-promise eslint-plugin-react
eslint-plugin-standard exports-loader extract-text-webpack-
plugin html-webpack-plugin husky imports-loader jest-cli json-
loader lodash marked moment node-sass postcss postcss-loader
raw-loader react react-addons-test-utils react-dom react-hot-
loader react-redux react-router redux rimraf sass-lint sass-
loader style-loader webpack webpack-dev-server whatwg-fetch
How I feel when there's a learning curve.
(Don't worry, you're not alone.)
©2015 T7
Q: "How do you
eat an elephant?"
A: "One bite at a time."
aka: When things seem daunting, break them down into smaller
chunks. Eventually, those chunks each become understandable.
NOTE:
First off, let me say that what I am showing
you today is simply "a" way to do React.
It is not necessarily "the" (right, only) way.
This is simply the approach we have settled
on, after trial and error with various projects.
One thing to keep in mind when working
with React is the oft-repeated phrase…
"Everything is a component."
A component is essentially anything
that looks like this: <UppercaseTag>
(Components may contain other components.)
Any time you see something like this…
<UppercaseTag />
<UppercaseTag> content </UppercaseTag>
…that is usually a React "class," which may or may
not be an actual JavaScript (ECMAScript 6) class.
For the purpose of this talk, let's assume they all are.
NOTE:
Syntax that looks like HTML but is
embedded (not simply within a string)
in JavaScript is referred to as "JSX."
It is an artificial construct that means:
React.createElement(UppercaseTag, …)
Conceptually, all React apps are structured like this.
– great-grandparent
–– grandparent
––– parent
–––– child
–––– child
–– grandparent
––– parent
–––– child
–––– child
Components talk to each other via "props."
<UppercaseTag foo='bar' />
^ Here, the parent of <UppercaseTag> is passing
down a prop called foo, with the value of 'bar'.
Within the UppercaseTag class, that is usable via…
this.props.foo // "bar"
Typically, in order for a child to talk to a parent, the parent
component passes a callback function prop to the child.
Here's an example of how we use our <Input /> component.
<Input
handleChange={
function (e, value) {
// `e` is the event.
// `value` is the *.value of the input.
}
}
/>
Q: What if the parent does not "care" about the grandparent or the
child, other than the fact that they are nested within one another?
– grandparent <—> "parent" props
–– parent <—> "grandparent" and "child" props
––– child <—> "parent" props
A: That is why Redux was created, to allow each component to
get and/or set changes to a shared object store, aka "app state."
– grandparent <—> Redux
–– parent
––– child <—> Redux
^ If the parent has no inherent reason to care about the shared
state, it need not be involved as an unnecessary middleman.
NOTE: Dan Abramov is
on the React team, and is
the creator of Redux.
NOTE: Ryan Florence is
one of the creators of
React Router. He does
not usually use Redux.
You may sometimes hear about local state as being confined to each
individual React component. That is correct. Components can have...
this.state.batmanIdentity // "Bruce Wayne"
this.state.checked // boolean
this.state.hasPlaceholder // boolean
this.state.value // string
…data that is internal. That self-contained state can be shared with child
components via props, and can be passed to parents via callback functions.
Redux "app state" makes things like this.props.foo available to multiple
components, from a source other than their parents. Redux is a "parent to all."
©2015 T7
I think of the relationship between HTML & JS like this:
Using jQuery or Angular is like
decorating trees in a forest.
Using React is like planting a
magic seed, from which a
decorated forest grows.
Angular apps usually
have "decorated" HTML,
with <tag ng-foo="…">
attributes sprinkled
throughout. HTML loads,
JS parses it, and then
applies functionality.
React apps usually have
a very minimal HTML
page, with a single
insertion point, such as
<div id="app"> and then
the rest of the markup is
generated entirely by JS.
Having full knowledge of the generated HTML, React is
able to keep track of the "virtual DOM" and do precise
updates accordingly. This means you rarely, if ever,
actually make any of your HTML changes directly.
No more typing… $('#foo').addClass('bar')
Anatomy of a React Component
NOTE:
This is an contrived example. You
would not normally use internal
state, when something is just
directly set via props anyway.
However, this illustrates the
relationship between state and
props. State is internal, whereas
props come from a component
that resides a "level above."
Anatomy of a React Component
NOTE:
Most of the time, you can safely
leave out the constructor. It is
called implicitly, if absent.
This example also shows how
you might use defaultProps, to
provide a fallback placeholder for
this.props.name. This is handy
when awaiting an Ajax request.
My React apps normally follow this hierarchy:
– <Provider>..........................// Redux.
–– <Router>...........................// Router.
––– <RouterContext>...................// Router.
–––– <Connect>........................// Redux.
––––– <Page>..........................// mine.
–––––– <App>..........................// mine.
––––––– <AppMain>.....................// mine.
–––––––– <ParentComponent>............// mine.
––––––––– <ChildComponent>............// mine!
–––––––––– // etc.
©2015 T7
Let's walk through the structure
of the T7 React starter project.
First, we will look at the initial index.js
file, and then progress further into the
"nested" JS components from there.
Lastly, we will fire it up in the browser.
How I feel about neatly nested nested React components.
bestpysanky.com/9-pcs-10-Semenov-Russian-Nesting-Dolls-p/nds09000.htm
This index.js file kicks off
the entire app. It pulls in
<Provider> as the first
component, which wraps
{routes} and makes
shared Redux "app
state" available.
In routes.js we have the
pattern matching of
various paths, and their
respective components.
We are also setting a
title prop that will be
added to the <title> tag
via a Page component.
This a simple <Page>
level component. In this
case, it is the fallback for
when a route is not
found. We are pulling in a
Markdown file, with a
basic "404" message.
It utilizes the <App>
layout component,
wrapping the content.
This is an example of the
<App> layout component,
which pulls in app level
header, main, footer, etc.
{this.props.children}
is the Markdown content,
passed forward from the
<Page> component.
This is the <AppHeader>
component, which was
being used from within
the <App> component. It
contains the logo, and a
few links in a list.
It is making use of the
"Unsemantic" grid, via
<Grid> components.
Here, the <AppMain>
component is basically
just a pass-through for
content, simply wrapping
it in <main role="main">
for accessibility and
styling purposes.
©2015 T7
So, that covers some of the app structure...
– index.js
– routes.js
– various "page" and "layout" components
Next, let's take a look at <Accordion>. It is a
component that maintains internal state, but
can also be overridden by its parent.
Accessibility is best when done with advanced planning. For the
components we build, we make sure it is not just an afterthought.
This is actually an example of
the <AccordionMulti>
component, a not mutually
exclusive version of the
<Accordion> component.
First, the initial selected
state is set, based on
props passed in from the
parent component.
If it does not exist, then
the accordion starts out
completely collapsed.
We also ensure a unique
id, to map ARIA roles to
various elements.
In the event that the parent
component wants to override
the internal state, we have
componentWillReceiveProps
which will potentially cause a
state change by calling…
this.setState({key:val})
The handleClick method
is called internally when
an accordion header is
clicked. This sets the
component state, and if a
this.props.handleClick
callback exists from the
parent, it will call it too.
Here, an otherwise
tedious process is made
fully automatic. That is,
obviating the manual
assignment of a unique
id to each header and
panel, in order to ensure
ARIA accessibility hooks
are properly associated
to their peer elements.
In the render method, ARIA
roles are set, based on the
internal component state.
For each section of accordion
content, a child component
<AccordionHeader> is created.
Also note, an accordion is
technically a role="tablist"
©2015 T7
Okay, so now we have a basic understanding
of how an accessible component works.
Let's now delve into how we can persist
component state across <Router> changes,
and potentially even across page reloads.
We will take a look at how a <Page> level
component is hooked up to Redux.
<Page> is like Tony Stark. Redux connect adds the "suit" to this.props
This is done through a process called "currying," when a function returns another, modified function.
First, we need to import
bindActionCreators and
connect from redux, and
react-redux. These will
allow us to make external
functions usable within
the <Page> component.
Next, we import our own
"actions" from the
various files we have
stored in the directory
"/source/redux/actions".
This directory is not to
be confused with NPM's
"/node_modules/redux".
At the end of the file, we
have Page.propTypes
validation, so that React
can warn us if the wrong
type of props are passed.
string vs. boolean, etc.
mapStateToProps is
where external "app
state" is added to <Page>
via this.props.*
mapDispatchToProps is
where external functions
are made available to
<Page> via this.props.*
Lastly, connect uses
"currying" to make these
changes innate to <Page>.
You could think of <Page> as
Tony Stark, and the result of
the connect call as wrapping
him in an Iron Man suit.
<Page> then has all the
additional props and functions
applied to it from Redux.
Thanks to the aforementioned
currying of connect, we now
have multiple "action"
methods available from
Redux, that can be called from
within our <Page> component.
When we actually make use of
<AccordionMulti> we pass in
the selectedFaqAccordion
"app state," and the callback
handleClickFaqAccordion
which triggers our Redux
"action" state change.
©2015 T7
Alright, so that is how things work on a
component level. But what is all this talk of
mapping state, mapping dispatch…
Where does that come from?
Glad you asked. Next, let's look at these Redux
concepts: actions, action types, and reducers.
The way Redux layers
together various state
changes into one object
reminds me of the SNL skit
"Taco Town" where they
wrap a hard-shell taco in a
soft-shell taco, in a crepe,
in a pizza, in a pancake,
that is deep fried…
In "/source/redux/index.js" we
have what is referred to as a
rootReducer, which
aggregates the various child
reducers. A common mistake
is to forget to add a new
reducer here. That can lead to
frustration when debugging.
In "/source/redux/_types.js"
there is a list of action types,
which have been assigned to
constants. While this may
seem silly, because they are
just strings, it enforces unique
action names. This is helpful
as your project grows larger.
Each reducer reads from the
aforementioned _types.js file,
and potentially pivots based
on what type of action it is.
In this case, we are saving
changes to the selected state
of the accordion. Notice that
the state is being get/set by
utils.storage, which allows
the state change to persist
across page loads, saved in
window.localStorage
This file makes the function
this.props.updateFaqAccordion
available to any component
where connect is used on it.
It passes forward any changes to
the accordion's selected state.
©2015 T7
And now, a word from our sponsors:
— ESLint
— Sass-Lint
— Jest & React Test Utils
#srslytho… Unit testing and code linting is
underrated. So, let's look at how that works.
npm run test
By default, Jest wants to be
helpful and "mock" every file you
include. But, we can just disable
that, as we know exactly what we
want to test. It speeds things up.
We give our test suite a name,
the same as our <UppercaseTag>.
Then, we render it into the
testing concept of a "document,"
and assign a parent reference.
Then we can use vanilla DOM
methods: querySelectorAll, etc.
For each aspect we want to test,
we pass a string and function to
"it" — made available by Jest.
it('does something', …)
Each resulting pass/fail is shown
in the command line, via…
npm run test
©2015 T7
Across various projects, we find it helpful to
have a set of utility methods, which we use by
attaching them to a parent object, utils.
Allow me to explain a few of the cool
and/or more frequently used methods:
— utils.ajax
— utils.save
In the "/source/utils/index.js" file,
we import various utility
methods, and bundle them under
a single object, named utils.
In the "/source/utils/_ajax.js" file,
we have a wrapper around
window.fetch — which is the
new HTML5 replacement for the
quirkiness of XMLHttpRequest.
You can specify a host, url,
method, params — sent as query
or body based on method — and
callbacks for success/error.
This file is not presently used in
the React starter project, but we
do make use of it in real projects
that require us to do Ajax.
I use this utils.save method
quite a bit, when I need to view
an API response that is too
cumbersome to read as JSON in
the browser's developer tools.
Instead, it causes the browser to
download a nicely formatted
*.json file, so I can scroll through
it using a text editor instead.
Clicking the Save JSON
button on the "/#/profile"
page of the demo app will
download a JSON file…
form_data.json
In it, you will see the
current state of the form
fields and their values.
Resources:
• facebook.github.io/react/docs/tutorial.html

• reactforbeginners.com

• egghead.io/series/react-fundamentals

• egghead.io/series/getting-started-with-react-router

• egghead.io/series/getting-started-with-redux

• code-cartoons.com/a-cartoon-intro-to-redux-3afb775501a6

• medium.com/@learnreact/container-components-c0e67432e005

• medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0

demo
+ q&a
Slides:
j.mp/getting-started-react
GitHub repo:
github.com/t7/react-starter
Me, on Twitter:
@nathansmith

More Related Content

What's hot

Maintainable JavaScript
Maintainable JavaScriptMaintainable JavaScript
Maintainable JavaScriptNicholas Zakas
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best PraticesChengHui Weng
 
Even more java script best practices
Even more java script best practicesEven more java script best practices
Even more java script best practicesChengHui Weng
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureManish Jangir
 
Interesting Facts About Javascript
Interesting Facts About JavascriptInteresting Facts About Javascript
Interesting Facts About JavascriptManish Jangir
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012Nicholas Zakas
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgetsvelveeta_512
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep DiveManish Jangir
 
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Christian Lilley
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011Nicholas Zakas
 
JavaScript promise
JavaScript promiseJavaScript promise
JavaScript promiseeslam_me
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayCodecademy Ren
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Eventsdmethvin
 
Solving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoCompleteSolving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoCompleteIsaacSchlueter
 
jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)Addy Osmani
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaExoLeaders.com
 

What's hot (20)

Maintainable JavaScript
Maintainable JavaScriptMaintainable JavaScript
Maintainable JavaScript
 
JavaScript Best Pratices
JavaScript Best PraticesJavaScript Best Pratices
JavaScript Best Pratices
 
Think Async in Java 8
Think Async in Java 8Think Async in Java 8
Think Async in Java 8
 
Even more java script best practices
Even more java script best practicesEven more java script best practices
Even more java script best practices
 
Javascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big PictureJavascript Prototypal Inheritance - Big Picture
Javascript Prototypal Inheritance - Big Picture
 
Interesting Facts About Javascript
Interesting Facts About JavascriptInteresting Facts About Javascript
Interesting Facts About Javascript
 
Maintainable JavaScript 2012
Maintainable JavaScript 2012Maintainable JavaScript 2012
Maintainable JavaScript 2012
 
Getting the Most Out of jQuery Widgets
Getting the Most Out of jQuery WidgetsGetting the Most Out of jQuery Widgets
Getting the Most Out of jQuery Widgets
 
Javascript Objects Deep Dive
Javascript Objects Deep DiveJavascript Objects Deep Dive
Javascript Objects Deep Dive
 
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
Scalable CSS You and Your Back-End Coders Can Love - @CSSConf Asia 2014
 
Maintainable JavaScript 2011
Maintainable JavaScript 2011Maintainable JavaScript 2011
Maintainable JavaScript 2011
 
Intro to jQuery
Intro to jQueryIntro to jQuery
Intro to jQuery
 
JavaScript promise
JavaScript promiseJavaScript promise
JavaScript promise
 
Lesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ayLesson 203 18 sep13-1500-ay
Lesson 203 18 sep13-1500-ay
 
jQuery 1.7 Events
jQuery 1.7 EventsjQuery 1.7 Events
jQuery 1.7 Events
 
The evolution of asynchronous javascript
The evolution of asynchronous javascriptThe evolution of asynchronous javascript
The evolution of asynchronous javascript
 
Solving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoCompleteSolving Real World Problems with YUI 3: AutoComplete
Solving Real World Problems with YUI 3: AutoComplete
 
jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)jQuery Performance Tips and Tricks (2011)
jQuery Performance Tips and Tricks (2011)
 
Good karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with KarmaGood karma: UX Patterns and Unit Testing in Angular with Karma
Good karma: UX Patterns and Unit Testing in Angular with Karma
 
Step objects
Step objectsStep objects
Step objects
 

Viewers also liked

Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & ReduxBoris Dinkevich
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJSAll Things Open
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.jsDoug Neiner
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentationThanh Tuong
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux IntroductionNikolaus Graf
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesomeAndrew Hull
 
Erlang抽象数据结构简介
Erlang抽象数据结构简介Erlang抽象数据结构简介
Erlang抽象数据结构简介Xiaozhe Wang
 
Lights camera action orlando - october 2015 -slide upload
Lights camera action   orlando - october 2015 -slide uploadLights camera action   orlando - october 2015 -slide upload
Lights camera action orlando - october 2015 -slide uploadtsmeans
 
Presentation on Graphical password-technology to make system more secured
Presentation on Graphical password-technology to make system more securedPresentation on Graphical password-technology to make system more secured
Presentation on Graphical password-technology to make system more securedSanjeev Kumar Jaiswal
 
Error Reports
Error ReportsError Reports
Error Reportsaurora444
 
Draft of Memory of the World Thailand Communication and Advocacy Plan
Draft of Memory of the World Thailand Communication and Advocacy PlanDraft of Memory of the World Thailand Communication and Advocacy Plan
Draft of Memory of the World Thailand Communication and Advocacy PlanRachabodin Suwannakanthi
 
C:\fakepath\psychological disorders
C:\fakepath\psychological disordersC:\fakepath\psychological disorders
C:\fakepath\psychological disordersSteve Kashdan
 
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk ilker KALDI
 
Digital Citizenship
Digital CitizenshipDigital Citizenship
Digital CitizenshipAndrew Kohl
 
95 Theses - The Cluetrain Manifesto
95 Theses - The Cluetrain Manifesto95 Theses - The Cluetrain Manifesto
95 Theses - The Cluetrain ManifestoJennifer Angiwot
 

Viewers also liked (20)

Introduction to React & Redux
Introduction to React & ReduxIntroduction to React & Redux
Introduction to React & Redux
 
React and redux
React and reduxReact and redux
React and redux
 
An Introduction to ReactJS
An Introduction to ReactJSAn Introduction to ReactJS
An Introduction to ReactJS
 
A Brief Introduction to React.js
A Brief Introduction to React.jsA Brief Introduction to React.js
A Brief Introduction to React.js
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
Reactjs
Reactjs Reactjs
Reactjs
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
React JS and why it's awesome
React JS and why it's awesomeReact JS and why it's awesome
React JS and why it's awesome
 
React js
React jsReact js
React js
 
Erlang抽象数据结构简介
Erlang抽象数据结构简介Erlang抽象数据结构简介
Erlang抽象数据结构简介
 
Lights camera action orlando - october 2015 -slide upload
Lights camera action   orlando - october 2015 -slide uploadLights camera action   orlando - october 2015 -slide upload
Lights camera action orlando - october 2015 -slide upload
 
Presentation on Graphical password-technology to make system more secured
Presentation on Graphical password-technology to make system more securedPresentation on Graphical password-technology to make system more secured
Presentation on Graphical password-technology to make system more secured
 
Kerala’S Scenary
Kerala’S ScenaryKerala’S Scenary
Kerala’S Scenary
 
Error Reports
Error ReportsError Reports
Error Reports
 
Draft of Memory of the World Thailand Communication and Advocacy Plan
Draft of Memory of the World Thailand Communication and Advocacy PlanDraft of Memory of the World Thailand Communication and Advocacy Plan
Draft of Memory of the World Thailand Communication and Advocacy Plan
 
C:\fakepath\psychological disorders
C:\fakepath\psychological disordersC:\fakepath\psychological disorders
C:\fakepath\psychological disorders
 
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk
Medya Araçlarına ve Toplumsal Etkilerine Tarihi Bir Yolculuk
 
Plagiarism.new
Plagiarism.newPlagiarism.new
Plagiarism.new
 
Digital Citizenship
Digital CitizenshipDigital Citizenship
Digital Citizenship
 
95 Theses - The Cluetrain Manifesto
95 Theses - The Cluetrain Manifesto95 Theses - The Cluetrain Manifesto
95 Theses - The Cluetrain Manifesto
 

Similar to Getting Started with React

Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodFITC
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 
30 days-of-react-ebook-fullstackio
30 days-of-react-ebook-fullstackio30 days-of-react-ebook-fullstackio
30 days-of-react-ebook-fullstackioimdurgesh
 
The complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrrThe complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrrAfreenK
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJSDaine Mawer
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core ConceptsDivyang Bhambhani
 
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 DeveloperFabrit Global
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsMike Wilcox
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaDavid Chandler
 
I Heard React Was Good
I Heard React Was GoodI Heard React Was Good
I Heard React Was GoodFITC
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]GDSC UofT Mississauga
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react jsStephieJohn
 
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardAndroid | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardJAX London
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistMark Fayngersh
 
Functional Components in Vue.js
Functional Components in Vue.jsFunctional Components in Vue.js
Functional Components in Vue.jsAustin Gil
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today Nitin Tyagi
 
The History of React-Hot-Loader
The History of React-Hot-LoaderThe History of React-Hot-Loader
The History of React-Hot-LoaderAnton Korzunov
 

Similar to Getting Started with React (20)

Ryan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was GoodRyan Christiani I Heard React Was Good
Ryan Christiani I Heard React Was Good
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 
30 days-of-react-ebook-fullstackio
30 days-of-react-ebook-fullstackio30 days-of-react-ebook-fullstackio
30 days-of-react-ebook-fullstackio
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
The complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrrThe complete-beginners-guide-to-react dyrr
The complete-beginners-guide-to-react dyrr
 
React a11y-csun
React a11y-csunReact a11y-csun
React a11y-csun
 
Introduction to ReactJS
Introduction to ReactJSIntroduction to ReactJS
Introduction to ReactJS
 
Reusable Apps
Reusable AppsReusable Apps
Reusable Apps
 
React js - The Core Concepts
React js - The Core ConceptsReact js - The Core Concepts
React js - The Core Concepts
 
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
 
Professional JavaScript: AntiPatterns
Professional JavaScript: AntiPatternsProfessional JavaScript: AntiPatterns
Professional JavaScript: AntiPatterns
 
The 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for JavaThe 90-Day Startup with Google AppEngine for Java
The 90-Day Startup with Google AppEngine for Java
 
I Heard React Was Good
I Heard React Was GoodI Heard React Was Good
I Heard React Was Good
 
Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]Full Stack React Workshop [CSSC x GDSC]
Full Stack React Workshop [CSSC x GDSC]
 
Fundamental concepts of react js
Fundamental concepts of react jsFundamental concepts of react js
Fundamental concepts of react js
 
Android | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted NewardAndroid | Busy Java Developers Guide to Android: UI | Ted Neward
Android | Busy Java Developers Guide to Android: UI | Ted Neward
 
The State of Front-end At CrowdTwist
The State of Front-end At CrowdTwistThe State of Front-end At CrowdTwist
The State of Front-end At CrowdTwist
 
Functional Components in Vue.js
Functional Components in Vue.jsFunctional Components in Vue.js
Functional Components in Vue.js
 
React - Start learning today
React - Start learning today React - Start learning today
React - Start learning today
 
The History of React-Hot-Loader
The History of React-Hot-LoaderThe History of React-Hot-Loader
The History of React-Hot-Loader
 

More from Nathan Smith

HTML5 Can't Do That
HTML5 Can't Do ThatHTML5 Can't Do That
HTML5 Can't Do ThatNathan Smith
 
Rapid Templating with Serve
Rapid Templating with ServeRapid Templating with Serve
Rapid Templating with ServeNathan Smith
 
Proactive Responsive Design
Proactive Responsive DesignProactive Responsive Design
Proactive Responsive DesignNathan Smith
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsNathan Smith
 
Adobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksAdobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksNathan Smith
 
Accelerated Grid Theming
Accelerated Grid ThemingAccelerated Grid Theming
Accelerated Grid ThemingNathan Smith
 
Urban Leadership Slides
Urban Leadership SlidesUrban Leadership Slides
Urban Leadership SlidesNathan Smith
 
Themes from Ascent of a Leader
Themes from Ascent of a LeaderThemes from Ascent of a Leader
Themes from Ascent of a LeaderNathan Smith
 
Marketing 450 Guest Lecture
Marketing 450 Guest LectureMarketing 450 Guest Lecture
Marketing 450 Guest LectureNathan Smith
 
Fundamental Design Principles
Fundamental Design PrinciplesFundamental Design Principles
Fundamental Design PrinciplesNathan Smith
 
Striking a Balance: Middle Ground in Front-End Development
Striking a Balance: Middle Ground in Front-End DevelopmentStriking a Balance: Middle Ground in Front-End Development
Striking a Balance: Middle Ground in Front-End DevelopmentNathan Smith
 
Echo Conference 2008
Echo Conference 2008Echo Conference 2008
Echo Conference 2008Nathan Smith
 

More from Nathan Smith (20)

HTML5 Can't Do That
HTML5 Can't Do ThatHTML5 Can't Do That
HTML5 Can't Do That
 
Rapid Templating with Serve
Rapid Templating with ServeRapid Templating with Serve
Rapid Templating with Serve
 
Proactive Responsive Design
Proactive Responsive DesignProactive Responsive Design
Proactive Responsive Design
 
Use Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile AppsUse Web Skills To Build Mobile Apps
Use Web Skills To Build Mobile Apps
 
Red Dirt JS
Red Dirt JSRed Dirt JS
Red Dirt JS
 
Refresh OKC
Refresh OKCRefresh OKC
Refresh OKC
 
DrupalCon jQuery
DrupalCon jQueryDrupalCon jQuery
DrupalCon jQuery
 
DSVC Design Talk
DSVC Design TalkDSVC Design Talk
DSVC Design Talk
 
Think Vitamin CSS
Think Vitamin CSSThink Vitamin CSS
Think Vitamin CSS
 
Adobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + FireworksAdobe MAX 2008: HTML/CSS + Fireworks
Adobe MAX 2008: HTML/CSS + Fireworks
 
Meet Clumsy
Meet ClumsyMeet Clumsy
Meet Clumsy
 
Echo HTML5
Echo HTML5Echo HTML5
Echo HTML5
 
Accelerated Grid Theming
Accelerated Grid ThemingAccelerated Grid Theming
Accelerated Grid Theming
 
Urban Leadership Slides
Urban Leadership SlidesUrban Leadership Slides
Urban Leadership Slides
 
Themes from Ascent of a Leader
Themes from Ascent of a LeaderThemes from Ascent of a Leader
Themes from Ascent of a Leader
 
7 Storey Mountain
7 Storey Mountain7 Storey Mountain
7 Storey Mountain
 
Marketing 450 Guest Lecture
Marketing 450 Guest LectureMarketing 450 Guest Lecture
Marketing 450 Guest Lecture
 
Fundamental Design Principles
Fundamental Design PrinciplesFundamental Design Principles
Fundamental Design Principles
 
Striking a Balance: Middle Ground in Front-End Development
Striking a Balance: Middle Ground in Front-End DevelopmentStriking a Balance: Middle Ground in Front-End Development
Striking a Balance: Middle Ground in Front-End Development
 
Echo Conference 2008
Echo Conference 2008Echo Conference 2008
Echo Conference 2008
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 

Recently uploaded (20)

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 

Getting Started with React

  • 1. ©2015 T7 October 13, 2015 April 28, 2016 Getting Started with React squaresconference.com
  • 3. • Father of two rambunctious boys, who are big fans of Star Wars and Legos.
 • Self-taught. That just means I pestered lots of people until I learned how to do this stuff. Yet, I still doubt myself daily.
 • I build the "legacy" software of tomorrow.
 • I generally have a "get off my lawn" attitude towards emerging technology. Nathan Smith Principal Front-End Architect Introduction
  • 4.
  • 5. Scientific* comparison of "React.js" versus "Angular.js" *Not really scientific.
  • 6. Perhaps unsurprisingly, my off the cuff, ill-informed reaction… ended up being totally wrong. (But, admitting when you're wrong is part of being a grown-up, right?)
  • 7. ©2015 T7 Software development is a field in which it is actually possible to know less % overall, even if you were to never forget anything. There are always new things to learn, because the total surface area is continuously expanding.
  • 8. Today, I would like to talk to you about the "three Rs." •Reading •wRiting •aRithmetic
  • 9. There are three fundamental aspects of most React apps. •React = the "V" (and "C") layer. •Redux = the "M" layer. •Router = um, the "URL" layer? :)
  • 10. PROOF POSITIVE OF COOL PROJECTS? LOGOS! github.com/reactjs/react-routergithub.com/reactjs/reduxgithub.com/facebook/react
  • 11. Actually, my projects are more like this. Accounting.js Babel ECMAScript 6+ ESLint Jest Lodash Markdown Moment.js NPM PostCSS React ReactDOM React Router React Test Utils Redux Sass (SCSS) Sass-Lint Standard Webpack window.fetch
  • 12. npm init -f && npm install --save-dev accounting autoprefixer babel-core babel-jest babel-loader babel-plugin-transform- runtime babel-preset-es2015 babel-preset-react babel-runtime copy-webpack-plugin cross-env css-loader es6-promise eslint eslint-config-standard eslint-config-standard-jsx eslint- config-standard-react eslint-plugin-promise eslint-plugin-react eslint-plugin-standard exports-loader extract-text-webpack- plugin html-webpack-plugin husky imports-loader jest-cli json- loader lodash marked moment node-sass postcss postcss-loader raw-loader react react-addons-test-utils react-dom react-hot- loader react-redux react-router redux rimraf sass-lint sass- loader style-loader webpack webpack-dev-server whatwg-fetch
  • 13. How I feel when there's a learning curve. (Don't worry, you're not alone.)
  • 14. ©2015 T7 Q: "How do you eat an elephant?" A: "One bite at a time." aka: When things seem daunting, break them down into smaller chunks. Eventually, those chunks each become understandable.
  • 15. NOTE: First off, let me say that what I am showing you today is simply "a" way to do React. It is not necessarily "the" (right, only) way. This is simply the approach we have settled on, after trial and error with various projects.
  • 16. One thing to keep in mind when working with React is the oft-repeated phrase… "Everything is a component." A component is essentially anything that looks like this: <UppercaseTag> (Components may contain other components.)
  • 17. Any time you see something like this… <UppercaseTag /> <UppercaseTag> content </UppercaseTag> …that is usually a React "class," which may or may not be an actual JavaScript (ECMAScript 6) class. For the purpose of this talk, let's assume they all are.
  • 18. NOTE: Syntax that looks like HTML but is embedded (not simply within a string) in JavaScript is referred to as "JSX." It is an artificial construct that means: React.createElement(UppercaseTag, …)
  • 19.
  • 20.
  • 21. Conceptually, all React apps are structured like this. – great-grandparent –– grandparent ––– parent –––– child –––– child –– grandparent ––– parent –––– child –––– child
  • 22. Components talk to each other via "props." <UppercaseTag foo='bar' /> ^ Here, the parent of <UppercaseTag> is passing down a prop called foo, with the value of 'bar'. Within the UppercaseTag class, that is usable via… this.props.foo // "bar"
  • 23. Typically, in order for a child to talk to a parent, the parent component passes a callback function prop to the child. Here's an example of how we use our <Input /> component. <Input handleChange={ function (e, value) { // `e` is the event. // `value` is the *.value of the input. } } />
  • 24. Q: What if the parent does not "care" about the grandparent or the child, other than the fact that they are nested within one another? – grandparent <—> "parent" props –– parent <—> "grandparent" and "child" props ––– child <—> "parent" props
  • 25. A: That is why Redux was created, to allow each component to get and/or set changes to a shared object store, aka "app state." – grandparent <—> Redux –– parent ––– child <—> Redux ^ If the parent has no inherent reason to care about the shared state, it need not be involved as an unnecessary middleman.
  • 26. NOTE: Dan Abramov is on the React team, and is the creator of Redux.
  • 27. NOTE: Ryan Florence is one of the creators of React Router. He does not usually use Redux.
  • 28. You may sometimes hear about local state as being confined to each individual React component. That is correct. Components can have... this.state.batmanIdentity // "Bruce Wayne" this.state.checked // boolean this.state.hasPlaceholder // boolean this.state.value // string …data that is internal. That self-contained state can be shared with child components via props, and can be passed to parents via callback functions. Redux "app state" makes things like this.props.foo available to multiple components, from a source other than their parents. Redux is a "parent to all."
  • 29. ©2015 T7 I think of the relationship between HTML & JS like this: Using jQuery or Angular is like decorating trees in a forest. Using React is like planting a magic seed, from which a decorated forest grows.
  • 30. Angular apps usually have "decorated" HTML, with <tag ng-foo="…"> attributes sprinkled throughout. HTML loads, JS parses it, and then applies functionality.
  • 31. React apps usually have a very minimal HTML page, with a single insertion point, such as <div id="app"> and then the rest of the markup is generated entirely by JS.
  • 32. Having full knowledge of the generated HTML, React is able to keep track of the "virtual DOM" and do precise updates accordingly. This means you rarely, if ever, actually make any of your HTML changes directly. No more typing… $('#foo').addClass('bar')
  • 33. Anatomy of a React Component NOTE: This is an contrived example. You would not normally use internal state, when something is just directly set via props anyway. However, this illustrates the relationship between state and props. State is internal, whereas props come from a component that resides a "level above."
  • 34. Anatomy of a React Component NOTE: Most of the time, you can safely leave out the constructor. It is called implicitly, if absent. This example also shows how you might use defaultProps, to provide a fallback placeholder for this.props.name. This is handy when awaiting an Ajax request.
  • 35. My React apps normally follow this hierarchy: – <Provider>..........................// Redux. –– <Router>...........................// Router. ––– <RouterContext>...................// Router. –––– <Connect>........................// Redux. ––––– <Page>..........................// mine. –––––– <App>..........................// mine. ––––––– <AppMain>.....................// mine. –––––––– <ParentComponent>............// mine. ––––––––– <ChildComponent>............// mine! –––––––––– // etc.
  • 36. ©2015 T7 Let's walk through the structure of the T7 React starter project. First, we will look at the initial index.js file, and then progress further into the "nested" JS components from there. Lastly, we will fire it up in the browser.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41. How I feel about neatly nested nested React components. bestpysanky.com/9-pcs-10-Semenov-Russian-Nesting-Dolls-p/nds09000.htm
  • 42. This index.js file kicks off the entire app. It pulls in <Provider> as the first component, which wraps {routes} and makes shared Redux "app state" available.
  • 43. In routes.js we have the pattern matching of various paths, and their respective components. We are also setting a title prop that will be added to the <title> tag via a Page component.
  • 44. This a simple <Page> level component. In this case, it is the fallback for when a route is not found. We are pulling in a Markdown file, with a basic "404" message. It utilizes the <App> layout component, wrapping the content.
  • 45. This is an example of the <App> layout component, which pulls in app level header, main, footer, etc. {this.props.children} is the Markdown content, passed forward from the <Page> component.
  • 46. This is the <AppHeader> component, which was being used from within the <App> component. It contains the logo, and a few links in a list. It is making use of the "Unsemantic" grid, via <Grid> components.
  • 47. Here, the <AppMain> component is basically just a pass-through for content, simply wrapping it in <main role="main"> for accessibility and styling purposes.
  • 48. ©2015 T7 So, that covers some of the app structure... – index.js – routes.js – various "page" and "layout" components Next, let's take a look at <Accordion>. It is a component that maintains internal state, but can also be overridden by its parent.
  • 49. Accessibility is best when done with advanced planning. For the components we build, we make sure it is not just an afterthought.
  • 50. This is actually an example of the <AccordionMulti> component, a not mutually exclusive version of the <Accordion> component.
  • 51. First, the initial selected state is set, based on props passed in from the parent component. If it does not exist, then the accordion starts out completely collapsed. We also ensure a unique id, to map ARIA roles to various elements.
  • 52. In the event that the parent component wants to override the internal state, we have componentWillReceiveProps which will potentially cause a state change by calling… this.setState({key:val})
  • 53. The handleClick method is called internally when an accordion header is clicked. This sets the component state, and if a this.props.handleClick callback exists from the parent, it will call it too.
  • 54. Here, an otherwise tedious process is made fully automatic. That is, obviating the manual assignment of a unique id to each header and panel, in order to ensure ARIA accessibility hooks are properly associated to their peer elements.
  • 55. In the render method, ARIA roles are set, based on the internal component state. For each section of accordion content, a child component <AccordionHeader> is created. Also note, an accordion is technically a role="tablist"
  • 56. ©2015 T7 Okay, so now we have a basic understanding of how an accessible component works. Let's now delve into how we can persist component state across <Router> changes, and potentially even across page reloads. We will take a look at how a <Page> level component is hooked up to Redux.
  • 57. <Page> is like Tony Stark. Redux connect adds the "suit" to this.props This is done through a process called "currying," when a function returns another, modified function.
  • 58. First, we need to import bindActionCreators and connect from redux, and react-redux. These will allow us to make external functions usable within the <Page> component.
  • 59. Next, we import our own "actions" from the various files we have stored in the directory "/source/redux/actions". This directory is not to be confused with NPM's "/node_modules/redux".
  • 60. At the end of the file, we have Page.propTypes validation, so that React can warn us if the wrong type of props are passed. string vs. boolean, etc.
  • 61. mapStateToProps is where external "app state" is added to <Page> via this.props.*
  • 62. mapDispatchToProps is where external functions are made available to <Page> via this.props.*
  • 63. Lastly, connect uses "currying" to make these changes innate to <Page>. You could think of <Page> as Tony Stark, and the result of the connect call as wrapping him in an Iron Man suit. <Page> then has all the additional props and functions applied to it from Redux.
  • 64. Thanks to the aforementioned currying of connect, we now have multiple "action" methods available from Redux, that can be called from within our <Page> component.
  • 65. When we actually make use of <AccordionMulti> we pass in the selectedFaqAccordion "app state," and the callback handleClickFaqAccordion which triggers our Redux "action" state change.
  • 66. ©2015 T7 Alright, so that is how things work on a component level. But what is all this talk of mapping state, mapping dispatch… Where does that come from? Glad you asked. Next, let's look at these Redux concepts: actions, action types, and reducers.
  • 67. The way Redux layers together various state changes into one object reminds me of the SNL skit "Taco Town" where they wrap a hard-shell taco in a soft-shell taco, in a crepe, in a pizza, in a pancake, that is deep fried…
  • 68.
  • 69. In "/source/redux/index.js" we have what is referred to as a rootReducer, which aggregates the various child reducers. A common mistake is to forget to add a new reducer here. That can lead to frustration when debugging.
  • 70. In "/source/redux/_types.js" there is a list of action types, which have been assigned to constants. While this may seem silly, because they are just strings, it enforces unique action names. This is helpful as your project grows larger.
  • 71. Each reducer reads from the aforementioned _types.js file, and potentially pivots based on what type of action it is. In this case, we are saving changes to the selected state of the accordion. Notice that the state is being get/set by utils.storage, which allows the state change to persist across page loads, saved in window.localStorage
  • 72. This file makes the function this.props.updateFaqAccordion available to any component where connect is used on it. It passes forward any changes to the accordion's selected state.
  • 73. ©2015 T7 And now, a word from our sponsors: — ESLint — Sass-Lint — Jest & React Test Utils #srslytho… Unit testing and code linting is underrated. So, let's look at how that works.
  • 75.
  • 76. By default, Jest wants to be helpful and "mock" every file you include. But, we can just disable that, as we know exactly what we want to test. It speeds things up.
  • 77. We give our test suite a name, the same as our <UppercaseTag>. Then, we render it into the testing concept of a "document," and assign a parent reference. Then we can use vanilla DOM methods: querySelectorAll, etc.
  • 78. For each aspect we want to test, we pass a string and function to "it" — made available by Jest. it('does something', …) Each resulting pass/fail is shown in the command line, via… npm run test
  • 79. ©2015 T7 Across various projects, we find it helpful to have a set of utility methods, which we use by attaching them to a parent object, utils. Allow me to explain a few of the cool and/or more frequently used methods: — utils.ajax — utils.save
  • 80. In the "/source/utils/index.js" file, we import various utility methods, and bundle them under a single object, named utils.
  • 81. In the "/source/utils/_ajax.js" file, we have a wrapper around window.fetch — which is the new HTML5 replacement for the quirkiness of XMLHttpRequest. You can specify a host, url, method, params — sent as query or body based on method — and callbacks for success/error. This file is not presently used in the React starter project, but we do make use of it in real projects that require us to do Ajax.
  • 82. I use this utils.save method quite a bit, when I need to view an API response that is too cumbersome to read as JSON in the browser's developer tools. Instead, it causes the browser to download a nicely formatted *.json file, so I can scroll through it using a text editor instead.
  • 83. Clicking the Save JSON button on the "/#/profile" page of the demo app will download a JSON file… form_data.json In it, you will see the current state of the form fields and their values.
  • 84. Resources: • facebook.github.io/react/docs/tutorial.html
 • reactforbeginners.com
 • egghead.io/series/react-fundamentals
 • egghead.io/series/getting-started-with-react-router
 • egghead.io/series/getting-started-with-redux
 • code-cartoons.com/a-cartoon-intro-to-redux-3afb775501a6
 • medium.com/@learnreact/container-components-c0e67432e005
 • medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0