React.js. a crash course. Jake Zimmerman January 29th, 2016

Similar documents
Lecture 8. ReactJS 1 / 24

Lesson: Web Programming(6) Omid Jafarinezhad Sharif University of Technology

React + React Native. Based on material by Danilo Filgueira

Frontend Frameworks Part 2. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Approaches to wrapping React. Thursday 3 September 15

Templates and Databinding. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Future Web App Technologies

Gearing Up for Development CS130(0)

Building an OpenLayers 3 map viewer with React

Xtern BOOTCAMP. Week 2 Day 1 May 22, 2017

React & Redux in Hulu. (Morgan Cheng)

JSX in Depth. Why JSX? The Transform. JSX is a JavaScript XML syntax transform recommended for use with React.

React(.js) the Domino Way High-Performance Client for Domino. Knut Herrmann

React Loadable: Code Splitting with Server Side Rendering

React. SWE 432, Fall Web Application Development

welcome to BOILERCAMP HOW TO WEB DEV

React native. State An overview. See the tutorials at

AngularJS Fundamentals

McLab tools on the web. Deepanjan Roy Supervisor: Prof. Laurie Hendren

Advanced React JS + Redux Development

React Not Just Hype!

Full Stack Developer with Java

JavaScript Fundamentals_

About the Tutorial. Audience. Prerequisites. Copyright & Disclaimer. ReactJS

DECOUPLING PATTERNS, SERVICES AND CREATING AN ENTERPRISE LEVEL EDITORIAL EXPERIENCE

React. HTML code is made up of tags. In the example below, <head> is an opening tag and </head> is the matching closing tag.

Frontend UI Training. Whats App :

Front End Nanodegree Syllabus

MEAP Edition Manning Early Access Program React Native in Action Developing ios and Android Apps with JavaScript Version 13

Building with React Native. Simon Ayzman Mobile Apps Bloomberg

Using Development Tools to Examine Webpages

COURSE 20480B: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Programming in HTML5 with JavaScript and CSS3

Getting Started with ReactJS

Testing & Performance. SWE 432, Fall 2016 Design and Implementation of Software for the Web

React tips. while building facebook-scale application

High Performance Single Page Application with Vue.js

COURSE OUTLINE MOC 20480: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

THE PRAGMATIC INTRO TO REACT. Clayton Anderson thebhwgroup.com WEB AND MOBILE APP DEVELOPMENT AUSTIN, TX

CISC 1600 Lecture 2.4 Introduction to JavaScript

Stencil: The Time for Vanilla Web Components has Arrived

ClojureScript. as a compilation target to JS. Michiel Vijay FP AMS October 16th 2014

Course 20480: Programming in HTML5 with JavaScript and CSS3

AngularJS Introduction

International Research Journal of Engineering and Technology (IRJET) e-issn: Volume: 05 Issue: 06 June p-issn:

Vue.js Framework. Internet Engineering. Spring Pooya Parsa Professor: Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

ReactJS and Webpack for Rails

Say No to Complexity!

AngularJS AN INTRODUCTION. Introduction to the AngularJS framework

widgetjs Documentation

Say No to Complexity!

Full Stack boot camp

55249: Developing with the SharePoint Framework Duration: 05 days

20480B: Programming in HTML5 with JavaScript and CSS3

Beyond JavaScript Frameworks: Writing Reliable Web Apps With. Elm. Erik Wendel DevDays Vilnius 2018

EWD Custom Tag Development. Built-in Custom Tags for defining and manipulating Javascript

Programming with the Finesse API

Design Document V2 ThingLink Startup

JavaScript CS 4640 Programming Languages for Web Applications

Modern and Responsive Mobile-enabled Web Applications

Client Side JavaScript and AJAX

Course Details. Skills Gained. Who Can Benefit. Prerequisites. View Online URL:

Session 7. JavaScript Part 2. W3C DOM Reading and Reference

תוכנית יומית לכנס התכנסות וארוחת בוקר

Programming in HTML5 with JavaScript and CSS3

Michiel DomCode, May 26th 2015

JavaScript Specialist v2.0 Exam 1D0-735

GRITS AJAX & GWT. Trey Roby. GRITS 5/14/09 Roby - 1

Learn Web Development CodersTrust Polska course outline. Hello CodersTrust! Unit 1. HTML Structuring the Web Prerequisites Learning pathway.

Welcome to CS50 section! This is Week 10 :(

Session 3: JavaScript - Structured Programming

2/6/2012. Rich Internet Applications. What is Ajax? Defining AJAX. Asynchronous JavaScript and XML Term coined in 2005 by Jesse James Garrett

Frontend II: Javascript and DOM Programming. Wednesday, January 7, 15

Human-Computer Interaction Design

JavaScript CS 4640 Programming Languages for Web Applications

Using AJAX to Easily Integrate Rich Media Elements

Welcome. Quick Introductions

We will talk about Alt-Tab from the usability perspective. Think about: - Is it learnable? - Is it efficient? - What about errors and safety?

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

What Is React Native?

TechWatch Report Javascript Libraries and Frameworks

extc Web Developer Rapid Web Application Development and Ajax Framework Using Ajax

a Very Short Introduction to AngularJS

"Charting the Course... Comprehensive Angular. Course Summary

Web Security, Summer Term 2012

Web Security, Summer Term 2012

A Brief Introduction to a web browser's HTML. and the Document Object Model (DOM) Lecture 28

BEFORE CLASS. If you haven t already installed the Firebug extension for Firefox, download it now from

1 CS480W Quiz 6 Solution

AJAX and JSON. Day 8

IN Development in Platform Ecosystems Lecture 2: HTML, CSS, JavaScript

X3DOM Getting declarative (X)3D into HTML

Modern SharePoint and Office 365 Development

JavaScript Introduction

Quick.JS Documentation

HTML 5: Fact and Fiction Nathaniel T. Schutta

Interactor Tree. Edith Law & Mike Terry

Manual Html A Href Onclick Submit Form

JavaScript Programming

Programming in HTML5 with JavaScript and CSS3

Transcription:

React.js a crash course Jake Zimmerman January 29th, 2016

Key Features of React.js Easily express user interfaces Richly express the visual elements of a design, as well as the interactions users can take on them Makes for better maintainability Abstracts the browser's DOM Write your UI modularly up front, then render it down to the platform you re using Render to the browser DOM, an HTML string (serverside!), or to native libraries (React Native) Data flows are predictable Control the flow to control the logic Flow is always onedirectional to avoid difficult to debug magic

JSX Syntax (two links)

JSX Syntax It s (basically) just HTML var MyComponent = React.createClass({ return ( <div> <h3>hello, world!</h3> <p>react is quite cool.</p> </div> ); ); Define and nest custom components var App = React.createClass({ return ( <div> <Heading /> <MyComponent /> <Footer /> </div> ); ); Embed JavaScript expressions var MyComponent = React.createClass({ return ( <div> <p>react is {this.props.adv cool.</p> </div> ); );... <MyComponent adj="remarkably" />...

JSX Syntax -- Gotcha! Always one node returned from render var MyComponent = React.createClass({ return ( <h3>hello, world!</h3> <p>react is quite cool.</p> ); ); INCORRECT: two nodes returned from render Need to use selfclosing tags var MyComponent = React.createClass({ return ( <div> <h3>hello, world!</h3> <hr> <p>react is quite cool.</p> </div> ); ); INCORRECT: hr takes no children (make selfclosing) <hr /> classname == class, htmlfor == for var MyComponent = React.createClass({ return ( <div> <h3 class="title"> Hello, world! </h3> </div> ); ); INCORRECT: class should be classname <h3 classname="title">

Component Specs and Lifecycle (link)

this.props & this.state this.props this.state var Contact = React.createClass({ return ( <div> <Header active="contact" /> <MyComponent adj="amazingly" /> <Footer date={today author="@jez" /> </div> ); ); var MyComponent = React.createClass({ getinitialstate: function() { return {enabled: false;, componentdidmount: function() { var data = asyncloaddata(); this.setstate(enabled: data.enabled);, if (this.state.enabled) { return <h3>hello, world!</h3>; else { return <h3>goodbye, world D:</h3>;, );

this.props & this.state this.props Used for initializing a component this.props is never mutated; don t try to overwrite anything in this.props this.state Used for determining when to re-render a component. this.state is also never mutated, but only for technical reasons. Use this.setstate() to mutate the state.

Some important lifecycle methods render Should be a pure function of props and state Basically, as long as you aren t trying to interact with global variables or the DOM you re fine. Lets React only re-render when needed. getinitialstate, proptypes Useful for initialization and handling edge cases. One note: don t copy props to state if you don t need to. componentdidmount Useful to populate your data asynchronously after we ve shown something to the user. Reminiscent of how most apps load some UI elements, and the data shows up later.

Example: + Queue (link)

From Design Mock to Implementation motivating idea: small, reusable components (actual) <Queue>... </Queue> <QueueItem />... <QueueItem action="check-off" />

Fetch the data // Uses jquery.get to handle AJAX calls componentdidmount: function() { return $.get("/api/queues/" + this.props.params.key, (queue) => this.setstate(queue)); // this.setstate() will notify React to re-render // Also, note how this encourages a clear separation // of concerns: your backend is just returning JSON, // your frontend takes the JSON and manipulates it.

Dive right in! The React documentation (both by Facebook and by the community) is amazing: Facebook s tutorial Another great React tutorial In practice, sometimes the hardest thing to get working with React is the compilation. References: Getting Started gulpfile.js Check these things out later: Flux ReactDOMServer React Native