What is React?
Hint: Developed by Facebook in 2011

A javascript library for building fast and interactive user interfaces
React is a library NOT a framework
currently the most popular JS library for building UI
dominating frameworks for building UI (over angular and vue)
developed at Facebook in 2011
Expand job opportunities, know react!
Used by Facebook, Uber, Netflix, Twitter, Pintrest, AirBnB

What is every React application?

A tree of components
each component is independent (UI element)
can build components in isolation + combination for UI
UI elements connected together in a tree:
Navbar
Profile
Feed
What is a component?

a piece of the user interface
built indepently, isolated, re-usable
compose to build complex user interfaces
implemented as a Javascript class
Contains:
state (data to display)
render method (JS object maps to DOM)
Don’t work with DOM API in browsers
Each App:
contains root component
additional components are children
React app is a tree of components

What do we no longer have to do when working with React?
only makes sure view is in sync with state
React is a library NOT a framework
No longer to write code to…
query and manipulate DOM
attach event handlers to DOM elements
Why?
React reacts to state changes (virtual DOM) and automatically updates DOM
What is a react element?

A plain javascript object that maps to DOM

not a real DOM object, just plain Javascript object represents DOM element
React keeps a lightweight representation of DOM in memory
when a change occurs, a new react element is generated
React then compares to real DOM and updates
How is JSX compiled?
Hint: React.createElement ( )

we don’t directly use React from ‘react’ in JSX but…
When JSX code is compiled React.createElement ( ) is called
output of JSX expression is a React element
Ex. type: h1, etc. part of virtual DOM
What is the difference between React and Angular?
React is only a library that helps maintain the view in synch with DOM
Angular is a framework (complete solution)
React has small API to learn
calling HTTP services, routing requires 3rd party libraries (Express)

What are two helpful extensions?
Hint: Simple React Snippets, Prettier

Prettier - helps fomat our code
React Snippets -
What does the create-react-app command do for us?

all config is done for you!
Set’s up React Project:
lightweight server - allows us to host our react app during production
webpack - bundle code together into small packages to optimize load time
babel - compiler lets us write modern Javascript code that works in older browsersoverride settings/customize?
npm run eject

What is jsx?
Hint: Javascipt XML

syntax to describe what UI will look like
compiler (bable) takes jsx converts to vanilla JS (browser can understand)
in components use jsx and leave it to bable to call react
Ex. Babeljs.io - takes jsx converts to regular Javascript

What does npx eject do to our app?

allows us to customize configuration
hidden complexities (Bable, webpack, etc) removed
package.json adds dependencies
can add our own webpack, etc.
npm run eject
WARNING
Don’t do this unless you’re an advanced developer

What is Mosh going to teach us about Full Stack architecture in this course?

He is going to show us how to talk to a Node/Express server
focus on frontend
node server running on different port
React app talk to (get / send) data + store in MongoDb
connect to a real Node/Express backend (get/store data in MongoDb)
code given is code created in Node course

What will we learn in this course?
Build a real world video rental application
Feel confident building other applications on your own!
Topics:
Javascript - basics (take his other courses)
Components - building blocks of React
Tables - pagination, searching, sorting (common in apps)
Forms - validation (common in apps)
Routing - taking user between pages
HTTP Services - how to talk to backend services (data in MongoDB)
Auth - services from node backend (Node vs. Firebase)
Deployment -

Used in more than half of React projects

Not every React project needs Redux
Focus on learning React FIRST
learn Redux NEXT
What are pre-requisites of learning React?
Hint: 3 months of Javascript programming
JS basics - teach how to think like programmer, solve programming problems
JS OOP - advanced topics
Basics:
Let / Const keywords
Objects
this
Arrow functions
Destructuring
Spread Operator
Classes
Modules

What is the problem with this code?
Hint: var keyword

variable shouldn’t be accessible outside of a function (scope)
loop variable is accessible outside for loop!
var keyword accessible inside fn defined
Solution?
ES6 declaring variables
Let - only accessible inside block
const - only accessible inside block (constants_

What is the difference between let and const?
Hint: scope limited to block, read only

const - cannot be redefined (read only)
not a variable, cannot be re-assigned
let - variable that can be defined
Use const vs let
use let only when you need to re-assign a variable

What should we know about objects?
accessing properties or methods:
dynamically - bracket notation
static - dot notation

How is the .this keyword diferent in Javascript than Java/C#?

doesn’t always reference current object
value of .this is determined by how a fn is called
if call a fn as a method in an object.this refers to that object
if call a fn as a standalone obj or outside a fn .this returns window obj (global obj)
in Java (.this) always references current obj

How do we bind .this to always reference the current object?
.bind( ) method
takes an arg (obj) that sets .this to point
value of this based on arg passed to .bind

What should we know about arrow functions?
fat arrow between params and body of fn

How does .this behave with arrow functions vs. anonymous functions?

arrow functions bind .this to current object
annonymous functions .this points to globl obj

What did ES6 introduce as a new method in Arrays?
Hint: very useful in rendering lists in React
Map method of Arrays
Very useful for rendering lists in React
callback function transforms each element in array
takes one item at a time, returns a new item
returns a new array
Ex. ${} argument placeholder -> whatever put inside is dynamically rendered at run time

What is object destructuring?
Modern JS feature seen in a LOT React apps
Need to extract value of properties and store in separate variables
