Model
Virtual
DOM
DOM
Interact with VirtualDOM
Data Data
Event Event
Slide 12
Slide 12 text
setState will trigger
render
Define your view
Slide 13
Slide 13 text
React calculate the diff
• Set state will mark the red dot
• React will find out the blue
dots
• Re-render with only the
modified dom
Source: https://facebook.github.io/react/img/blog/react-diff-tree.png
Slide 14
Slide 14 text
Fast without spaghetti
Slide 15
Slide 15 text
Let focus on Logic
Slide 16
Slide 16 text
State inconsistency
Very common in single page webapp
Slide 17
Slide 17 text
State inconsistency
• Server sync not sync with client state
• item missing
• duplicate item
• State between client not sync
• State panic with poor internet
Slide 18
Slide 18 text
Flux fix that
Slide 19
Slide 19 text
It is a pattern
A pattern enforcing
unidirectional data flow
Flux is not framework
Slide 20
Slide 20 text
View
Action
Store
Dispatcher
Server
Slide 21
Slide 21 text
Unidirectional data flow
• Faster debug
• Faster on boarding
• Faster iteration
• Less cascading effect