27

Writing Scalable React Applications: Introduction

Embed Size (px)

Citation preview

Page 1: Writing Scalable React Applications: Introduction
Page 2: Writing Scalable React Applications: Introduction

Web history

Page 3: Writing Scalable React Applications: Introduction

React is small

Page 4: Writing Scalable React Applications: Introduction

Development tools

Page 5: Writing Scalable React Applications: Introduction

Trending

Page 6: Writing Scalable React Applications: Introduction

Prerequisite

Page 7: Writing Scalable React Applications: Introduction

Babel ▫ babel-preset-react▫ babel-preset-es2015▫ babel-plugin-transform-class-properties

Page 8: Writing Scalable React Applications: Introduction

What is React? ▫ No models▫ No controllers▫ No templates▫ No directives▫ No services▫ Only components

Page 9: Writing Scalable React Applications: Introduction

React Components

Page 10: Writing Scalable React Applications: Introduction

EmployeeList

Page 11: Writing Scalable React Applications: Introduction

JSX ▫ Syntax sugar for Javascript▫ Similar to HTML▫ Still Javascript▫ HTML attributes = JSX properties▫ Transpiled by Babel

Page 12: Writing Scalable React Applications: Introduction

JSX after transpile

Page 13: Writing Scalable React Applications: Introduction

EmployeeListItem

Page 14: Writing Scalable React Applications: Introduction

Lifecycle Methods

Page 15: Writing Scalable React Applications: Introduction

Component state

Page 16: Writing Scalable React Applications: Introduction

Use state in render

Page 17: Writing Scalable React Applications: Introduction

Add handlers

Page 18: Writing Scalable React Applications: Introduction

Use function passed via props

Page 19: Writing Scalable React Applications: Introduction

Break UI into components

Establish communication between components using props

Page 20: Writing Scalable React Applications: Introduction

Virtual DOM ▫ Result of render()▫ Simple object representing DOM▫ Very fast

Page 21: Writing Scalable React Applications: Introduction

Virtual DOM benchmarks

Page 22: Writing Scalable React Applications: Introduction

Render 1000 elements

Page 23: Writing Scalable React Applications: Introduction

Reconciliation ▫ Initial render() call▫ Save result (snapshot)▫ Update component (setState or props

change)▫ Lifecycle methods▫ Call render()▫ Compare snapshots▫ Update only changed nodes

Page 24: Writing Scalable React Applications: Introduction

Updating DOM node

Page 25: Writing Scalable React Applications: Introduction

To be continued.. ▫ Lifecycle methods▫ DOM events▫ Application structure▫ Data organization

Page 27: Writing Scalable React Applications: Introduction

Questions?