Top Banner
17

React JS Belgium Touch Base - React, Flux, React Native

Aug 21, 2015

Download

Technology

Philos.io
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: React JS Belgium Touch Base - React, Flux, React Native
Page 2: React JS Belgium Touch Base - React, Flux, React Native
Page 3: React JS Belgium Touch Base - React, Flux, React Native

@philos_io

Introduction to ReactJS

Page 4: React JS Belgium Touch Base - React, Flux, React Native

Agenda

ReactJSFlux

Architecture

React Native

Learn Once, Write Everywhere!

Page 5: React JS Belgium Touch Base - React, Flux, React Native
Page 6: React JS Belgium Touch Base - React, Flux, React Native

What is React?

UI Compone

nts

Virtual DOM

Immutable data

Can be used with any other frameworks (Ember, Angular…)

Abstract away the DOM and does all operations on the VD before updating the real DOM

Data flow in one direction, which brings a simple model to reason about.

Page 7: React JS Belgium Touch Base - React, Flux, React Native

More about React

• JavaScript Library for building UI, only UI

• Focus on rendering or V in MVC

• Implements unidirectional data flow

• Can power native apps with React Native

• Built and maintains by Facebook

ReactJS

Page 8: React JS Belgium Touch Base - React, Flux, React Native

ReactJS: Building a book store

JSX Syntax

var Book = React.createClass({ render: function() { return <div>Title: {this.props.title}</div>; }});

JSX Compiler

React.render(<Book title="React" />, document.body);

Page 9: React JS Belgium Touch Base - React, Flux, React Native

ReactJS: Building a book store

JS Syntax

var Book = React.createClass({displayName: "Book", render: function() { return React.createElement("div", null, "Title: ", this.props.title); }});

React.render(React.createElement(Book, {title: "React"}), document.body);

Page 10: React JS Belgium Touch Base - React, Flux, React Native

ReactJS: Building a book storeimport React from 'react';import Header from './components/header';import Main from './components/main';import Footer from './components/Footer';

var BookStore = React.createClass({render: function(){

return (<div>

<Header/><Main/><Footer/>

</div>);

}});

React.render(<BookStore/>, document.getElementById('wrapper'));

ES6 import module

Create the component

Page 11: React JS Belgium Touch Base - React, Flux, React Native

Flux Architecture

Flux Architecture

Actions Dispatchers Stores React

Page 12: React JS Belgium Touch Base - React, Flux, React Native

Flux Architecture

Page 13: React JS Belgium Touch Base - React, Flux, React Native

React Native in a nutshell

Touch Handling

Native Compone

nts

Styles &

Layout

ES6 support out of

the box

Extensibility

Polyfill

Page 14: React JS Belgium Touch Base - React, Flux, React Native

React vs. React Native

var Book = React.createClass({ render: function() {   return <div>

<span>Title: {this.props.title}</span></div>;

 }});

var Book = React.createClass({ render: function() {   return <View>

<Text>Title: {this.props.title}</Text>

</View>; }});

React React Native

Render natively inside their environment

Page 15: React JS Belgium Touch Base - React, Flux, React Native

React Native’s workflow ?

Workflow

$ npm install react-native-cli -g

$ react-native init whatsapp

$ cd whatsapp

$ Open whatsapp on Xcode

$ Build and run whatsapp

Useful command

$ CMD+D or Crtl+D to open contextual window

$ CMD+R to refresh

Page 16: React JS Belgium Touch Base - React, Flux, React Native

To Be Continued…

Page 17: React JS Belgium Touch Base - React, Flux, React Native