Rangle.io: React Training
master
master
  • Rangle React Training Materials
  • lessons
    • redux-hello
    • react-summary
    • redux-action-reducer
    • react-outline
    • react-container
    • redux-intro
    • redux-connect
    • react-component
    • advanced
    • redux-store
    • redux-logging
    • redux-thunk
    • react-cardlist
    • redux-merge
    • react-lifecycles
    • react-intro
  • CONDUCT
  • misc
    • summary
    • refs
    • overview
    • guide
    • gloss
  • LICENSE
  • index
  • rough-slides
    • react-training-slides
  • CONTRIBUTING
Powered by GitBook
On this page
  • [fit] Rangle.io
  • [fit] React Training
  • Prerequisites
  • Overview
  • [fit] 🤷🏽‍♂️ Ecmascript 2015
  • [fit] 🙋🏾‍♂️ Ecmascript 2015 Examples
  • [fit] Functional Programming
  • [fit] with JavaScript
  • Pure Functions
  • Pure Functions (Slice vs. Splice)
  • Map, Filter & Reduce
  • Currying
  • Currying add
  • Currying add
  • Currying add With ES6
  • [fit] React
  • Journey to React
  • jQuery
  • Templates
  • AngularJS
  • First Gen. SPA Frameworks
  • [fit] How Is React Different?
  • [fit] views as pure
  • [fit] stateless functions
  • [fit] View(Data) ➡️ HTML
  • React
  • Hello, world!
  • [fit] JSX
  • JSX 🤷🏽‍♂️
  • JSX?
  • JSX
  • Virtual DOM
  • React Terminology
  • [fit] Components
  • Hello Component
  • Composition
  • Thinking in Components
  • Atomic Design Principles
  • Atomic Design Principles
  • Atoms
  • Molecules
  • Organisms
  • Ecosystem
  • Environment
  • Quiz
  • Task
  • [fit] 🤖 Robodex
  • Let's Code!
  • Card

Was this helpful?

  1. rough-slides

react-training-slides

[fit] Rangle.io

[fit] React Training

Prerequisites

  • Access to the command line

  • Node.js (v6 or higher)

  • NPM (v3 or higher)

  • Code editor (Sublime, Atom, etc.)

  • Some JavaScript knowledge (ES5/ES6)

Overview

  • ES6

  • Light functional JavaScript

  • From jQuery to React

  • Thinking in Components

  • create-react-app

  • Components

    • JSX

    • State & Props

    • Stateless components

    • Stateful components

    • Lifecycle methods

    • PropTypes

    • DOM mounting

  • REST API (fetch)

[fit] 🤷🏽‍♂️ Ecmascript 2015

[fit] Functional Programming

[fit] with JavaScript

Pure Functions

A function where the return value is only determined by

  • its input values

  • without observable side effects

const add = (a, b) => a + b;

Pure Functions (Slice vs. Splice)

let letters = ["a", "b", "c"]

letters.slice(1)
// returns ["b", "c"], where letters is still ["a", "b", "c"]

letters.splice(1)
// returns ["b", "c"], where letters is now ["a"]

Map, Filter & Reduce

Array helper methods map, filter and reduce are examples of functional programming, which take in functions and do not mutate the original array.

Currying

A technique of converting a function that takes multiple arguments into a sequence of functions, each with a single argument.

f (a, b, c) ↔️ f(a)(b)(c)

Currying add

function add (a, b) {
  return a + b;
}

add(1, 2); // returns 3

// Curryed add()
function add (a) {
  return function(b) {
    return a + b ;
  }
}

Currying add

// returns a function where a = 2
const add2 = add(2);

// returns 5
add2(3);

Currying add With ES6

const add = a => b => a + b;

[fit] React

Journey to React

  • Direct DOM manipulation/jQuery

  • Templates

  • Template based frameworks such as AngularJS

jQuery

<article class="card">
  <img class="card-image"
    src="/img/avatar_1.jpg"
    title="Photo of a robot staring at you">

  <h1 class="card-title">Leanne Graham</h1>

  <a class="card-link"
    href="mailto:sincere@april.biz">
    sincere@april.biz
  </a>
</article>
// handle events
$('.card').click(function() { /* do something */ });

Templates

<article class="card">
  <img class="card-image"
    src="{{ robot.image }}"
    title="{{ robot.title }}">

  <h1 class="card-title">{{ robot.name }}</h1>

  <a class="card-link"
    href="mailto:{{ robot.email }}">
    {{ robot.email }}
  </a>
</article>
// handle events
$('.card').click(function() { /* do something */ });

AngularJS

<article class="card" ng-click="doSomething(robot)">
  <img class="card-image"
    src="{{ robot.image }}"
    title="{{ robot.title }}">

  <h1 class="card-title">{{ robot.name }}</h1>

  <a class="card-link"
    href="mailto:{{ robot.email }}">
    {{ robot.email }}
  </a>
</article>
// update data
robot.name = 'Ervin Howell';

First Gen. SPA Frameworks

  • Renders the DOM using templates

  • Manages DOM updates when data changes

  • Manages event bindings (click, scroll, etc.)

[fit] How Is React Different?

[fit] views as pure

[fit] stateless functions

[fit] View(Data) ➡️ HTML

React

  • No templates

  • Define UI as components

    • connected to data

  • Re-renders the whole world when data changes

  • Manages event bindings

Hello, world!

// in app.js
ReactDOM.render(
  <h1 className="title">Hello, world!</h1>,
  document.getElementById('root')
);
<!-- in index.html -->
<div id="root"></div>

[fit] JSX

JSX 🤷🏽‍♂️

<h1 className="title">Hello, world!</h1>

JSX?

function createElement(type, text) {
  const el = document.createElement(type);
  const textNode = document.createTextNode(text);
  el.appendChild(textNode);
  return el;
}

const h1 = (text) => createElement(`h1`, text);

// and then
document.body.appendChild(
  h1(`Hello, world!`)
);

JSX

// JS
createElement('h1', { className: `title` }, `Hello, world.`)

//JSX
<h1 className="title">Hello, world.</h1>

Virtual DOM

React Terminology

  • Virtual DOM ✅

  • JSX ✅

  • State

  • Props

  • Children

  • Stateless vs Stateful Components

  • Presentational vs Container Components

[fit] Components

Hello Component

const Hello = (props) => {
  return (
    <div className="f1 tc">
      <div>Hello World</div>
      <div>Welcome to {props.company}</div>
    </div>
  );
};

Composition

<Form>
  <FormGroup>
    <Label>Username</Label>
    <Input name="username" />

    <Label>Password</Label>
    <Input name="password" />
  </FormGroup>

  <Button>Submit</Button>
</Form>

Thinking in Components

Atomic Design Principles

We're not designing pages, we're designing systems of components -- – Stephen Hay

Atomic Design Principles

Atoms

  • Simplest building block

  • HTML tags

  • Easily styled

  • Highly reusable

  • Not very useful on their own

Molecules

<Form onSubmit={ onSubmit }>
  <Label>Search</Label>
  <Input type="text" value={ search } />

  <Button type="submit">Search</Button>
</Form>

Organisms

<Header>
  <Navigator>
    <Brand />
    <NavItem to="home">Home</NavItem>
    <NavItem to="about">About</NavItem>
    <NavItem to="blog">Blog</NavItem>
  </Navigator>
  <SearchForm />
</Header>

Ecosystem

  • What the client will see

  • Connected containers

  • Many components that make up a view

Environment

  • Root Component

  • Typically the <App /> component

  • Represents everything packaged together as an application

Component Hierarchy

Component Hierarchy

  • FilterableProductTable

  • SearchBar

  • ProductTable

  • ProductCategoryRow

  • ProductRow

Quiz

Breakdown the Mockup

Task

Breakdown the Mockup

  • Header

  • Navigator

  • NavigatorLink

  • Content

  • ProfileCard

  • ProfileImage

Let's Code!

$ npm install -g create-react-app
$ create-react-app robo-dex

Card

<RobotCard> ├ <Card> ├ <Media> ├ <Heading> └ <SubHeading>

Previousrough-slidesNextCONTRIBUTING

Last updated 5 years ago

Was this helpful?

[fit]

[fit]

🙋🏾‍♂️ Ecmascript 2015 Examples
🙋🏾‍♂️ examples
🙋🏾‍♂️ example
🙋🏾‍♂️ full example
🤖 Robodex
right fit
fit original
fit right
fit right
fit inline
right fit
left fit
inline 400% original
right fit original
right fit
right fit
right original 100%
original 150%