(Go: >> BACK << -|- >> HOME <<)

SlideShare a Scribd company logo
React Development with the MERN Stack
Cowork South Bay 22 + 23 April 2017
Troy Miles
• Troy Miles aka the RocknCoder
• Over 38 years of programming
experience
• Speaker and author
• bit.ly/rc-jquerybook
• rockncoder@gmail.com
• @therockncoder
• Now a lynda.com Author!

React Development with the MERN Stack
Agenda
• Introduction
• MERN cli
• Node.js & Express
• MongoDB & Mongoose
• React
• Redux
• React-Router
• Ajax
• React-Bootstrap
• Summary
Tools
• install Git
• install Node.js
• upgrade npm npm install npm -g
• install the MERN CLI, npm install -g mern-cli
Versions
app command my version
git git —version 2.12.2
node.js node -v v7.9.0
npm npm —v 4.2.0
ECMAScript Versions
Version Date
ES1 June 1997
ES2 June 1998
ES3 December 1999
ES4 DOA 2006
ES5 December 2009
ES6/ES2015 June 2015
ES2016 2016
Array Operators
• .isArray()
• .every()
• .forEach()
• .indexOf()
• .lastIndexOf()
• .some()
• .map()
• .reduce()
• .filter()
forEach
let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];

let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];

let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

console.log(nums);



// forEach iterates over the array, once for each element, but there is no way to
// break out

nums.forEach(function (elem, index, arr) {

console.log(index + ': ' + elem);

});



map
let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];

let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];

let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

console.log(nums);



// map iterates over all of the elements and returns a new array with the same
// number of elements

let nums2 = nums.map((elem) => elem * 2);

console.log(nums2);

filter
let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];

let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];

let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

console.log(nums);



// filter iterates over the array and returns a new array with only the elements
// that pass the test

let nums3 = nums.filter((elem) => !!(elem % 2));

console.log(nums3);
reduce
let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];

let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];

let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

console.log(nums);



// reduce iterates over the array passing the previous value and the current

// element it is up to you what the reduction does, let's concatenate the strings

let letters2 = letters.reduce((previous, current) => previous + current);

console.log(letters2);



// reduceRight does the same but goes from right to left

let letters3 = letters.reduceRight((previous, current) => previous + current);

console.log(letters3);

every
let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];

let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];

let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

console.log(nums);



// every makes sure that all the elements match the expression

let isEveryNumbers = junk.every((elem) => typeof elem === 'number');

console.log('Are all members of junk numbers: ' + isEveryNumbers);



let
• let allows us to create a block scoped variables
• they live and die within their curly braces
• best practice is to use let instead of var
let
// let allows us to create block scoped variables

// they live and die within the curly braces

let val = 2;

console.info(`val = ${val}`);

{

let val = 59;

console.info(`val = ${val}`);

}

console.info(`val = ${val}`);



const
• const creates a variable that can't be changed
• best practice is to make any variable that should
not change a constant
• does not apply to object properties or array
elements
const
const name = 'Troy';

console.info(`My name is ${name}`);

// the line below triggers a type error

name = 'Miles';

Template strings
• Defined by using opening & closing back ticks
• Templates defined by ${JavaScript value}
• The value can be any simple JavaScript expression
• Allows multi-line strings (return is pass thru)
Template strings
let state = 'California';

let city = 'Long Beach';

console.info(`This weekend's workshop is in ${city}, ${state}.`);



// template strings can run simple expressions like addition

let cup_coffee = 4.5;

let cup_tea = 2.5;

console.info(`coffee: $${cup_coffee} + tea: $${cup_tea} = $$
{cup_coffee + cup_tea}.`);



// they can allow us to create multi-line strings

console.info(`This is line #1.

this is line #2.`);



Arrow functions
• Succinct syntax
• Doesn’t bind its own this, arguments, or super
• Facilitate a more functional style of coding
• Can’t be used as constructors
Arrow functions
• When only one parameter, parenthesis optional
• When zero or more than one parameter,
parenthesis required
Arrow function
let anon_func = function (num1, num2) {

return num1 + num2;

};

console.info(`Anonymous func: ${anon_func(1, 2)}`);



let arrow_func = (num1, num2) => num1 + num2;

console.info(`Arrow func: ${arrow_func(3, 4)}`);

this
• this is handle different in arrow functions
• In anonymous function this is bound to the global
object
• In arrow
• One important difference between anonymous and
arrow functions is
import
• Imports functions, objects, or primitives from other
files
• import <name> from “<module name>”;
Destructuring
Object Destructuring
16// this is a demo of the power of destructuring
17// we have two objects with the same 3 properties
18 const binary = {kb: 1024, mb: 1048576, gb: 1073741824};
19 const digital = {kb: 1000, mb: 1000000, gb: 1000000000};
20// We use a ternary statement to choose which object
21// assign properties based on their property names
22 const {kb, mb, gb} = (useBinary) ? binary : digital;
Spread syntax
• Expands an expression in places where multiple
arguments, elements, or variables are expected
Vital Definitions
• state
• mutation
• immutable
• pure functions
Application Root Directory
• All of the commands, for all of the tools are
designed work on the application root directory
• If used anywhere else bad things will happen
• be sure you are in the app root
• double check that you are in the app root
Webpack
Webpack
• Module bundler
• Replaces System.JS
• Works with JS, CSS, and HTML
• Minifies, concatenates, and bundles
How?
• Webpack starts at your app’s entry point
• It makes a graph of all of its dependencies
• It then bundles them together into an output file
Loaders
• Goal: Webpack handler loading of all of your app’s
assets
• Every file is a module
• Webpack only understands only JavaScript
• Loaders transform files into modules
Rules
• test: Identifies the file’s type
• use: Transform the file with a plugin loader
Example #1
module: {
rules: [
{
test: /.json$/,
loader: 'json-loader',
},
Example #2
module: {
rules: [
{
test: /.jsx*$/,
exclude: [/node_modules/, /.+.config.js/],
loader: 'babel-loader',
},
Example #3{
test: /.css$/,
use: [
{
loader: 'style-loader',
options: {
sourceMap: true
}
},
{
loader: 'css-loader',
options: {
modules: true,
importLoaders: 1,
localIdentName: '[path]___[name]__[local]___[hash:base64:5]'
}
},
{
loader: 'postcss-loader'
}
],
},
Babel
Babel
• The compiler for writing the next generation
JavaScript
• current version 6.23.0
• works better with Webpack
Babel
• It is modular, with a small lightweight core
• Functionality comes from plugins
• All plugin are opt-in
Presets
• You might need a dozen plugins
• Keep track of them would be burdensome
• Presets are groups of related plugins
• Two popular ones are babel-preset-es2015 and
babel-preset-react
React
React
• A JavaScript library for building user interfaces
• Created by Facebook & Instagram
• Initial release March 2013
• Current version 15.4.2
• (Highly recommend reading their license)
React
• Virtual DOM
• One-way data flow
• JSX - JavaScript eXtension allows in HTML
generation
• Component-based
Component
• Fundamental building block of React
• Can be created with a JS Class or Function
React.PropTypes
• React.PropTypes is deprecated
• It will be deleted in React 16
• Use the npm package “prop-types” instead
• import	PropTypes	from	‘prop-types’;
Flux
• Application architecture for building user interfaces
• A pattern for managing data flow in your app
• One way data flow
• 4 main parts: Dispatcher, Store, Action, & View
The 4 main parts
• Dispatcher: receives actions & dispatches them to
stores
• Store: holds the data of an app
• Action: define app’s internal API
• View: displays the data from stores
React Development with the MERN Stack
Redux
Redux
• A predictable state container for JS apps
• Works well with React Native
• An alternative to & inspired by Flux
• Single store for the entire app
• Makes it easier to hot-load your app
• Created by Dan Abramov
3 Fundamental Principals
• Single Source of Truth
• State is Read-Only
• Changes are Made with Pure Functions
React-Redux
• Provides binds to React bindings to redux
• npm	i	-S	react-redux	
• Separates presentational and container
components
Container Components
• A React component which uses store.subscribe
• Could be created by hand, but easier using
connect()
• All containers need to access to the Redux store
• React-Redux includes <Provider> component for
store access
React Router
• A complete routing library for React
• Keeps UI in sync with URL
Node.js
Don’t use sudo
• Using sudo with npm is not a best practice
• sudo chown -R $USER /usr/local
• The command makes you the owner of your local
directory
• That enables apps your in that directory like npm,

able to work without more permissions
Node 7
• New version of Chrome V8
• Supports ES6
• Faster
• node -v
Express
Express
• Web framework for Node.js
• Like Rails is to Ruby
• We will use for routing and first page
mLab
https://mlab.com/
mLab
• Sign up for the Sandbox plan
• It comes with 0.5 GB of space
• Support is included
Connection Info
• From the home page
• Click on your db
• In the upper left is your info
• Copy the shell connect info
MongoDB
Who Uses MongoDB
• Craigslist
• eBay
• Foursquare
• SourceForge
• Viacom
• Expedia
• Parse
• LinkedIn
• Medtronic
• eHarmony
• CERN
• and more
Features
• Document Database
• High Performance
• High Availability
• Easy Scalability
• Geospatial Data
Document
• An ordered set of keys and values
• like JavaScript objects
• no duplicate keys allowed
• type and case sensitive
• field order is not important nor guaranteed
Mongo Shell Remotely
• mongo	ds045054.mlab.com:45054/quiz	-u	<dbuser>	-p	<dbpassword>	
• <dbuser>	is	your	database	user	name	
• <dbpassword>	is	your	database	password
Shell Commands
• show dbs
• use <database name>
• show collections
• db.<collection name>.drop()
Queries
• db.<collection name>.find(<query>)
• skip()
• limit()
• sort()
• pretty()
Insert & Delete Data
• insert()
• remove(<query>)
Environment Variables
• process.env object holds environment vars
• Reading: var dbConnect =
process.env.dbConnect;
• Writing: process.env.mode = ‘test’;
Heroku Environment Vars
• Reading - heroku config
• heroku config:get var-name
• Writing - heroku config:set var=value
• heroku config:unset var-name
Setting Environment Vars
• http://bit.ly/rc-setenv
• Mac terminal - export variable=value
Mongoose
Mongoose
• Object Data Modeling (ODM)
• Mongoose makes MongoDB easier to work with
• Makes it easier to connect and to work with objects
Mongoose
• npm install mongoose —save
• var mongoose = require(‘mongoose’);
• mongoose.connect(<connection string>);
Mongoose Schema Types
• Array
• Boolean
• Buffer
• Date
• Mixed
• Number
• ObjectId
• String
Links
• https://git-scm.com/downloads
• https://nodejs.org/en/
• http://expressjs.com/
• https://www.heroku.com/
• https://mlab.com/
Links
• https://facebook.github.io/react/
• http://redux.js.org/
• https://reacttraining.com/react-router/
Summary
• React is good
• Redux makes it better
• Combine with Node & MongoDB to create
lightweight Web Apps

More Related Content

What's hot

Intro to React
Intro to ReactIntro to React
Intro to React
Justin Reock
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
洪 鹏发
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
DivyanshGupta922023
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
Emanuele DelBono
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
Nikolaus Graf
 
Reactjs
ReactjsReactjs
React JS
React JSReact JS
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
Smile Gupta
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
Thanh Tuong
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
Sergey Romaneko
 
React Context API
React Context APIReact Context API
React Context API
NodeXperts
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
Hamid Ghorbani
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
jguerrero999
 
MERN PPT
MERN PPTMERN PPT
React - Introdução
React - IntroduçãoReact - Introdução
React - Introdução
Jefferson Mariano de Souza
 
Introduction à React
Introduction à ReactIntroduction à React
Introduction à React
Thibault Martinez
 
React event
React eventReact event
React event
Ducat
 
React js
React jsReact js
React workshop
React workshopReact workshop
React workshop
Imran Sayed
 
Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_
ForceBolt
 

What's hot (20)

Intro to React
Intro to ReactIntro to React
Intro to React
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
An introduction to React.js
An introduction to React.jsAn introduction to React.js
An introduction to React.js
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Reactjs
ReactjsReactjs
Reactjs
 
React JS
React JSReact JS
React JS
 
Getting Started with React.js
Getting Started with React.jsGetting Started with React.js
Getting Started with React.js
 
ReactJS presentation
ReactJS presentationReactJS presentation
ReactJS presentation
 
React JS - Introduction
React JS - IntroductionReact JS - Introduction
React JS - Introduction
 
React Context API
React Context APIReact Context API
React Context API
 
Reactjs Basics
Reactjs BasicsReactjs Basics
Reactjs Basics
 
Node Architecture and Getting Started with Express
Node Architecture and Getting Started with ExpressNode Architecture and Getting Started with Express
Node Architecture and Getting Started with Express
 
MERN PPT
MERN PPTMERN PPT
MERN PPT
 
React - Introdução
React - IntroduçãoReact - Introdução
React - Introdução
 
Introduction à React
Introduction à ReactIntroduction à React
Introduction à React
 
React event
React eventReact event
React event
 
React js
React jsReact js
React js
 
React workshop
React workshopReact workshop
React workshop
 
Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_Next.js vs React | what to choose for frontend development_
Next.js vs React | what to choose for frontend development_
 

Similar to React Development with the MERN Stack

React Native One Day
React Native One DayReact Native One Day
React Native One Day
Troy Miles
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
Troy Miles
 
Intro to React
Intro to ReactIntro to React
Intro to React
Troy Miles
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
Troy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
Troy Miles
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
Troy Miles
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
Oswald Campesato
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
David Padbury
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
Eduard Tomàs
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
Codemotion
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
Quinton Sheppard
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
Ivano Malavolta
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
Troy Miles
 
Unit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptxUnit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptx
Lovely Professional University
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
Lovely Professional University
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
BoneyGawande
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
旻琦 潘
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
Troy Miles
 
Wider than rails
Wider than railsWider than rails
Wider than rails
Alexey Nayden
 
React native
React nativeReact native

Similar to React Development with the MERN Stack (20)

React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Angular Weekend
Angular WeekendAngular Weekend
Angular Weekend
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Node Boot Camp
Node Boot CampNode Boot Camp
Node Boot Camp
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1Game Design and Development Workshop Day 1
Game Design and Development Workshop Day 1
 
Angular2 for Beginners
Angular2 for BeginnersAngular2 for Beginners
Angular2 for Beginners
 
JavaScript Growing Up
JavaScript Growing UpJavaScript Growing Up
JavaScript Growing Up
 
JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)JavaScript in 2016 (Codemotion Rome)
JavaScript in 2016 (Codemotion Rome)
 
JavaScript in 2016
JavaScript in 2016JavaScript in 2016
JavaScript in 2016
 
Awesomeness of JavaScript…almost
Awesomeness of JavaScript…almostAwesomeness of JavaScript…almost
Awesomeness of JavaScript…almost
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Angular Application Testing
Angular Application TestingAngular Application Testing
Angular Application Testing
 
Unit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptxUnit-2 Getting Input from User.pptx
Unit-2 Getting Input from User.pptx
 
Getting Input from User
Getting Input from UserGetting Input from User
Getting Input from User
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
From MEAN to the MERN Stack
From MEAN to the MERN StackFrom MEAN to the MERN Stack
From MEAN to the MERN Stack
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
React native
React nativeReact native
React native
 

More from Troy Miles

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
Troy Miles
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
Troy Miles
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
Troy Miles
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
Troy Miles
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
Troy Miles
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
Troy Miles
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
Troy Miles
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
Troy Miles
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
Troy Miles
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
Troy Miles
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
Troy Miles
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
Troy Miles
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
Troy Miles
 
AngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic FrameworkAngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic Framework
Troy Miles
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile Apps
Troy Miles
 
Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-js
Troy Miles
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
Troy Miles
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
Troy Miles
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
Troy Miles
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
Troy Miles
 

More from Troy Miles (20)

Fast C++ Web Servers
Fast C++ Web ServersFast C++ Web Servers
Fast C++ Web Servers
 
AWS Lambda Function with Kotlin
AWS Lambda Function with KotlinAWS Lambda Function with Kotlin
AWS Lambda Function with Kotlin
 
ReactJS.NET
ReactJS.NETReactJS.NET
ReactJS.NET
 
What is Angular version 4?
What is Angular version 4?What is Angular version 4?
What is Angular version 4?
 
Functional Programming in JavaScript
Functional Programming in JavaScriptFunctional Programming in JavaScript
Functional Programming in JavaScript
 
Functional Programming in Clojure
Functional Programming in ClojureFunctional Programming in Clojure
Functional Programming in Clojure
 
MEAN Stack Warm-up
MEAN Stack Warm-upMEAN Stack Warm-up
MEAN Stack Warm-up
 
The JavaScript You Wished You Knew
The JavaScript You Wished You KnewThe JavaScript You Wished You Knew
The JavaScript You Wished You Knew
 
Build a Game in 60 minutes
Build a Game in 60 minutesBuild a Game in 60 minutes
Build a Game in 60 minutes
 
Quick & Dirty & MEAN
Quick & Dirty & MEANQuick & Dirty & MEAN
Quick & Dirty & MEAN
 
A Quick Intro to ReactiveX
A Quick Intro to ReactiveXA Quick Intro to ReactiveX
A Quick Intro to ReactiveX
 
JavaScript Foundations Day1
JavaScript Foundations Day1JavaScript Foundations Day1
JavaScript Foundations Day1
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 
AngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic FrameworkAngularJS on Mobile with the Ionic Framework
AngularJS on Mobile with the Ionic Framework
 
Building Cross-Platform Mobile Apps
Building Cross-Platform Mobile AppsBuilding Cross-Platform Mobile Apps
Building Cross-Platform Mobile Apps
 
Cross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-jsCross Platform Game Programming with Cocos2d-js
Cross Platform Game Programming with Cocos2d-js
 
10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips10 Groovy Little JavaScript Tips
10 Groovy Little JavaScript Tips
 
Cross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic FrameworkCross Platform Mobile Apps with the Ionic Framework
Cross Platform Mobile Apps with the Ionic Framework
 
Ionic framework one day training
Ionic framework one day trainingIonic framework one day training
Ionic framework one day training
 
Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8Cocos2d-x C++ Windows 8 &Windows Phone 8
Cocos2d-x C++ Windows 8 &Windows Phone 8
 

Recently uploaded

一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
williamrobertherman
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
Ortus Solutions, Corp
 
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
Ortus Solutions, Corp
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
confluent
 
YouTube SEO Mastery ......................
YouTube SEO Mastery ......................YouTube SEO Mastery ......................
YouTube SEO Mastery ......................
islamiato717
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Sparity1
 
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava... @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava...
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
DiyaSharma6551
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
ayushiqss
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
Ortus Solutions, Corp
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
shivamt017
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio, Inc.
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
Ortus Solutions, Corp
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
DNUG e.V.
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
sachin chaurasia
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
Mona Rathore
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
TwisterTools
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
Ortus Solutions, Corp
 

Recently uploaded (20)

一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
 
Design system: The basis for a consistent design
Design system: The basis for a consistent designDesign system: The basis for a consistent design
Design system: The basis for a consistent design
 
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
ColdBox Debugger v4.2.0: Unveiling Advanced Debugging Techniques for ColdBox ...
 
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
Break data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud ConnectorsBreak data silos with real-time connectivity using Confluent Cloud Connectors
Break data silos with real-time connectivity using Confluent Cloud Connectors
 
YouTube SEO Mastery ......................
YouTube SEO Mastery ......................YouTube SEO Mastery ......................
YouTube SEO Mastery ......................
 
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptxAddressing the Top 9 User Pain Points with Visual Design Elements.pptx
Addressing the Top 9 User Pain Points with Visual Design Elements.pptx
 
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava... @Call @Girls in Ahmedabad 🐱‍🐉  XXXXXXXXXX 🐱‍🐉  Best High Class Ahmedabad Ava...
@Call @Girls in Ahmedabad 🐱‍🐉 XXXXXXXXXX 🐱‍🐉 Best High Class Ahmedabad Ava...
 
AI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdfAI Chatbot Development – A Comprehensive Guide  .pdf
AI Chatbot Development – A Comprehensive Guide  .pdf
 
BoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and DebuggerBoxLang Developer Tooling: VSCode Extension and Debugger
BoxLang Developer Tooling: VSCode Extension and Debugger
 
Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.Shivam Pandit working on Php Web Developer.
Shivam Pandit working on Php Web Developer.
 
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data PlatformAlluxio Webinar | 10x Faster Trino Queries on Your Data Platform
Alluxio Webinar | 10x Faster Trino Queries on Your Data Platform
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
ANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdfANSYS Mechanical APDL Introductory Tutorials.pdf
ANSYS Mechanical APDL Introductory Tutorials.pdf
 
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S... @Call @Girls in Solapur 🤷‍♂️  XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
@Call @Girls in Solapur 🤷‍♂️ XXXXXXXX 🤷‍♂️ Tanisha Sharma Best High Class S...
 
What is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for FreeWhat is OCR Technology and How to Extract Text from Any Image for Free
What is OCR Technology and How to Extract Text from Any Image for Free
 
Web Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox ProWeb Hosting with CommandBox and CommandBox Pro
Web Hosting with CommandBox and CommandBox Pro
 

React Development with the MERN Stack

  • 1. React Development with the MERN Stack Cowork South Bay 22 + 23 April 2017
  • 2. Troy Miles • Troy Miles aka the RocknCoder • Over 38 years of programming experience • Speaker and author • bit.ly/rc-jquerybook • rockncoder@gmail.com • @therockncoder • Now a lynda.com Author!

  • 4. Agenda • Introduction • MERN cli • Node.js & Express • MongoDB & Mongoose • React • Redux • React-Router • Ajax • React-Bootstrap • Summary
  • 5. Tools • install Git • install Node.js • upgrade npm npm install npm -g • install the MERN CLI, npm install -g mern-cli
  • 6. Versions app command my version git git —version 2.12.2 node.js node -v v7.9.0 npm npm —v 4.2.0
  • 7. ECMAScript Versions Version Date ES1 June 1997 ES2 June 1998 ES3 December 1999 ES4 DOA 2006 ES5 December 2009 ES6/ES2015 June 2015 ES2016 2016
  • 8. Array Operators • .isArray() • .every() • .forEach() • .indexOf() • .lastIndexOf() • .some() • .map() • .reduce() • .filter()
  • 9. forEach let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];
 let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
 console.log(nums);
 
 // forEach iterates over the array, once for each element, but there is no way to // break out
 nums.forEach(function (elem, index, arr) {
 console.log(index + ': ' + elem);
 });
 

  • 10. map let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];
 let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
 console.log(nums);
 
 // map iterates over all of the elements and returns a new array with the same // number of elements
 let nums2 = nums.map((elem) => elem * 2);
 console.log(nums2);

  • 11. filter let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];
 let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
 console.log(nums);
 
 // filter iterates over the array and returns a new array with only the elements // that pass the test
 let nums3 = nums.filter((elem) => !!(elem % 2));
 console.log(nums3);
  • 12. reduce let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];
 let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
 console.log(nums);
 
 // reduce iterates over the array passing the previous value and the current
 // element it is up to you what the reduction does, let's concatenate the strings
 let letters2 = letters.reduce((previous, current) => previous + current);
 console.log(letters2);
 
 // reduceRight does the same but goes from right to left
 let letters3 = letters.reduceRight((previous, current) => previous + current);
 console.log(letters3);

  • 13. every let junk = [1, 2, 3, 4, 'Alpha', 5, {name: 'Jason'}];
 let letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K'];
 let nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
 console.log(nums);
 
 // every makes sure that all the elements match the expression
 let isEveryNumbers = junk.every((elem) => typeof elem === 'number');
 console.log('Are all members of junk numbers: ' + isEveryNumbers);
 

  • 14. let • let allows us to create a block scoped variables • they live and die within their curly braces • best practice is to use let instead of var
  • 15. let // let allows us to create block scoped variables
 // they live and die within the curly braces
 let val = 2;
 console.info(`val = ${val}`);
 {
 let val = 59;
 console.info(`val = ${val}`);
 }
 console.info(`val = ${val}`);
 

  • 16. const • const creates a variable that can't be changed • best practice is to make any variable that should not change a constant • does not apply to object properties or array elements
  • 17. const const name = 'Troy';
 console.info(`My name is ${name}`);
 // the line below triggers a type error
 name = 'Miles';

  • 18. Template strings • Defined by using opening & closing back ticks • Templates defined by ${JavaScript value} • The value can be any simple JavaScript expression • Allows multi-line strings (return is pass thru)
  • 19. Template strings let state = 'California';
 let city = 'Long Beach';
 console.info(`This weekend's workshop is in ${city}, ${state}.`);
 
 // template strings can run simple expressions like addition
 let cup_coffee = 4.5;
 let cup_tea = 2.5;
 console.info(`coffee: $${cup_coffee} + tea: $${cup_tea} = $$ {cup_coffee + cup_tea}.`);
 
 // they can allow us to create multi-line strings
 console.info(`This is line #1.
 this is line #2.`);
 

  • 20. Arrow functions • Succinct syntax • Doesn’t bind its own this, arguments, or super • Facilitate a more functional style of coding • Can’t be used as constructors
  • 21. Arrow functions • When only one parameter, parenthesis optional • When zero or more than one parameter, parenthesis required
  • 22. Arrow function let anon_func = function (num1, num2) {
 return num1 + num2;
 };
 console.info(`Anonymous func: ${anon_func(1, 2)}`);
 
 let arrow_func = (num1, num2) => num1 + num2;
 console.info(`Arrow func: ${arrow_func(3, 4)}`);

  • 23. this • this is handle different in arrow functions • In anonymous function this is bound to the global object • In arrow • One important difference between anonymous and arrow functions is
  • 24. import • Imports functions, objects, or primitives from other files • import <name> from “<module name>”;
  • 26. Object Destructuring 16// this is a demo of the power of destructuring 17// we have two objects with the same 3 properties 18 const binary = {kb: 1024, mb: 1048576, gb: 1073741824}; 19 const digital = {kb: 1000, mb: 1000000, gb: 1000000000}; 20// We use a ternary statement to choose which object 21// assign properties based on their property names 22 const {kb, mb, gb} = (useBinary) ? binary : digital;
  • 27. Spread syntax • Expands an expression in places where multiple arguments, elements, or variables are expected
  • 28. Vital Definitions • state • mutation • immutable • pure functions
  • 29. Application Root Directory • All of the commands, for all of the tools are designed work on the application root directory • If used anywhere else bad things will happen • be sure you are in the app root • double check that you are in the app root
  • 31. Webpack • Module bundler • Replaces System.JS • Works with JS, CSS, and HTML • Minifies, concatenates, and bundles
  • 32. How? • Webpack starts at your app’s entry point • It makes a graph of all of its dependencies • It then bundles them together into an output file
  • 33. Loaders • Goal: Webpack handler loading of all of your app’s assets • Every file is a module • Webpack only understands only JavaScript • Loaders transform files into modules
  • 34. Rules • test: Identifies the file’s type • use: Transform the file with a plugin loader
  • 35. Example #1 module: { rules: [ { test: /.json$/, loader: 'json-loader', },
  • 36. Example #2 module: { rules: [ { test: /.jsx*$/, exclude: [/node_modules/, /.+.config.js/], loader: 'babel-loader', },
  • 37. Example #3{ test: /.css$/, use: [ { loader: 'style-loader', options: { sourceMap: true } }, { loader: 'css-loader', options: { modules: true, importLoaders: 1, localIdentName: '[path]___[name]__[local]___[hash:base64:5]' } }, { loader: 'postcss-loader' } ], },
  • 38. Babel
  • 39. Babel • The compiler for writing the next generation JavaScript • current version 6.23.0 • works better with Webpack
  • 40. Babel • It is modular, with a small lightweight core • Functionality comes from plugins • All plugin are opt-in
  • 41. Presets • You might need a dozen plugins • Keep track of them would be burdensome • Presets are groups of related plugins • Two popular ones are babel-preset-es2015 and babel-preset-react
  • 42. React
  • 43. React • A JavaScript library for building user interfaces • Created by Facebook & Instagram • Initial release March 2013 • Current version 15.4.2 • (Highly recommend reading their license)
  • 44. React • Virtual DOM • One-way data flow • JSX - JavaScript eXtension allows in HTML generation • Component-based
  • 45. Component • Fundamental building block of React • Can be created with a JS Class or Function
  • 46. React.PropTypes • React.PropTypes is deprecated • It will be deleted in React 16 • Use the npm package “prop-types” instead • import PropTypes from ‘prop-types’;
  • 47. Flux • Application architecture for building user interfaces • A pattern for managing data flow in your app • One way data flow • 4 main parts: Dispatcher, Store, Action, & View
  • 48. The 4 main parts • Dispatcher: receives actions & dispatches them to stores • Store: holds the data of an app • Action: define app’s internal API • View: displays the data from stores
  • 50. Redux
  • 51. Redux • A predictable state container for JS apps • Works well with React Native • An alternative to & inspired by Flux • Single store for the entire app • Makes it easier to hot-load your app • Created by Dan Abramov
  • 52. 3 Fundamental Principals • Single Source of Truth • State is Read-Only • Changes are Made with Pure Functions
  • 53. React-Redux • Provides binds to React bindings to redux • npm i -S react-redux • Separates presentational and container components
  • 54. Container Components • A React component which uses store.subscribe • Could be created by hand, but easier using connect() • All containers need to access to the Redux store • React-Redux includes <Provider> component for store access
  • 55. React Router • A complete routing library for React • Keeps UI in sync with URL
  • 57. Don’t use sudo • Using sudo with npm is not a best practice • sudo chown -R $USER /usr/local • The command makes you the owner of your local directory • That enables apps your in that directory like npm,
 able to work without more permissions
  • 58. Node 7 • New version of Chrome V8 • Supports ES6 • Faster • node -v
  • 60. Express • Web framework for Node.js • Like Rails is to Ruby • We will use for routing and first page
  • 62. mLab • Sign up for the Sandbox plan • It comes with 0.5 GB of space • Support is included
  • 63. Connection Info • From the home page • Click on your db • In the upper left is your info • Copy the shell connect info
  • 65. Who Uses MongoDB • Craigslist • eBay • Foursquare • SourceForge • Viacom • Expedia • Parse • LinkedIn • Medtronic • eHarmony • CERN • and more
  • 66. Features • Document Database • High Performance • High Availability • Easy Scalability • Geospatial Data
  • 67. Document • An ordered set of keys and values • like JavaScript objects • no duplicate keys allowed • type and case sensitive • field order is not important nor guaranteed
  • 68. Mongo Shell Remotely • mongo ds045054.mlab.com:45054/quiz -u <dbuser> -p <dbpassword> • <dbuser> is your database user name • <dbpassword> is your database password
  • 69. Shell Commands • show dbs • use <database name> • show collections • db.<collection name>.drop()
  • 70. Queries • db.<collection name>.find(<query>) • skip() • limit() • sort() • pretty()
  • 71. Insert & Delete Data • insert() • remove(<query>)
  • 72. Environment Variables • process.env object holds environment vars • Reading: var dbConnect = process.env.dbConnect; • Writing: process.env.mode = ‘test’;
  • 73. Heroku Environment Vars • Reading - heroku config • heroku config:get var-name • Writing - heroku config:set var=value • heroku config:unset var-name
  • 74. Setting Environment Vars • http://bit.ly/rc-setenv • Mac terminal - export variable=value
  • 76. Mongoose • Object Data Modeling (ODM) • Mongoose makes MongoDB easier to work with • Makes it easier to connect and to work with objects
  • 77. Mongoose • npm install mongoose —save • var mongoose = require(‘mongoose’); • mongoose.connect(<connection string>);
  • 78. Mongoose Schema Types • Array • Boolean • Buffer • Date • Mixed • Number • ObjectId • String
  • 79. Links • https://git-scm.com/downloads • https://nodejs.org/en/ • http://expressjs.com/ • https://www.heroku.com/ • https://mlab.com/
  • 81. Summary • React is good • Redux makes it better • Combine with Node & MongoDB to create lightweight Web Apps