REACT
A JAVASCRIPT LIBRARY FOR BUILDING USER INTERFACES
- Introduction -
Presentation by Quangbuu Le <quangbuu@lozi.vn>
REACT
AsV in server-side MVC
REACT
AsV+C in client-side MVC
PHILOSOPHY
• DOM manipulation is expensive - not good	

• Simple - easy to contribute code	

• One-way reactive data-flow
COMPONENTS
• Write components, not
templates.	

• It’s reusable.	

• It’s high cohesion.
SPAGHETTI CODE? SAY NO
• Keep your component small.	

• It’s contain display logic only. No AJAX, no heavy
computing data in component.
HANDLE UI
• It’s hard because there is so much state.	

• Lots of UI elements, mutable DOM, user
input…	

• Data change over time is a root of all problems.
HOW COMPONENT WORKS?
• Render to Element with initialState before insert to DOM.	

• Component “react” when state change (on click, data
receive..).	

• Re-render the whole component, then diff with old virtual
DOM.	

• Apply the changed (attribute or DOM Node) to real
DOM.
• Re-render the whole component to make sure
that every place data is display correctly and to
be up-to-date.	

• Re-render make things simple: no magical data
binding, no model dirty checking, no explicit
DOM operations…	

• Is re-rendering expensive? No, thank to virtual
DOM.
VIRTUAL DOM
• Make re-rendering fast.	

• Re-rendering make new virtual DOM, then diff
with old virtual DOM to find changed.	

• Apply only changed to the real DOM.
It’s fast because real DOM is slow.
It’s powerful because every single component has own
power.
Thanks for listening
-The end -

React Introduction

  • 1.
    REACT A JAVASCRIPT LIBRARYFOR BUILDING USER INTERFACES - Introduction - Presentation by Quangbuu Le <quangbuu@lozi.vn>
  • 2.
  • 3.
  • 4.
    PHILOSOPHY • DOM manipulationis expensive - not good • Simple - easy to contribute code • One-way reactive data-flow
  • 5.
    COMPONENTS • Write components,not templates. • It’s reusable. • It’s high cohesion.
  • 6.
    SPAGHETTI CODE? SAYNO • Keep your component small. • It’s contain display logic only. No AJAX, no heavy computing data in component.
  • 7.
    HANDLE UI • It’shard because there is so much state. • Lots of UI elements, mutable DOM, user input… • Data change over time is a root of all problems.
  • 8.
    HOW COMPONENT WORKS? •Render to Element with initialState before insert to DOM. • Component “react” when state change (on click, data receive..). • Re-render the whole component, then diff with old virtual DOM. • Apply the changed (attribute or DOM Node) to real DOM.
  • 9.
    • Re-render thewhole component to make sure that every place data is display correctly and to be up-to-date. • Re-render make things simple: no magical data binding, no model dirty checking, no explicit DOM operations… • Is re-rendering expensive? No, thank to virtual DOM.
  • 10.
    VIRTUAL DOM • Makere-rendering fast. • Re-rendering make new virtual DOM, then diff with old virtual DOM to find changed. • Apply only changed to the real DOM.
  • 11.
    It’s fast becausereal DOM is slow.
  • 12.
    It’s powerful becauseevery single component has own power.
  • 13.