29
Introduction to React Rob Quick

Introduction to React

Embed Size (px)

Citation preview

Page 1: Introduction to React

Introduction to React

Rob Quick

Page 2: Introduction to React

Brief History of React

2011: Created internally at FB.2012: Instagram acquired by FB. Begins re-write of their front-end.2013: Open sourced at JSConf.

Page 3: Introduction to React

Guiding Principles

Page 4: Introduction to React

Declarative/Composable

Page 5: Introduction to React
Page 6: Introduction to React

Everything is a ‘component’

Page 7: Introduction to React

Data flows in one direction.

Page 8: Introduction to React

How everyone else does it…

• Model View Controller (MVC) • Model View ViewModel (MVVM)• Model View *Something*

Page 9: Introduction to React

Re-render everything anytime anything changes.

Page 10: Introduction to React

Virtual DOM

Page 11: Introduction to React

How React Does It

1. On every update, React builds a new Virtual DOM representation of your application.

Page 12: Introduction to React

How React Does It

2. It then compares the new representation against the previous one, and determines what has changed.

Page 13: Introduction to React

How React Does It

3. It decides what individual change to the DOM are required to reflect this new state. Each change is placed in a queue.

Page 14: Introduction to React

How React Does It

4. Finally, it batch updates the DOM based on the changes in the queue.

Page 15: Introduction to React

<Code />

Page 16: Introduction to React

Source: https://facebook.github.io/react/docs/tutorial.html

Page 17: Introduction to React

Source: https://facebook.github.io/react/docs/tutorial.html

Page 18: Introduction to React

Source: https://facebook.github.io/react/docs/tutorial.html

Page 19: Introduction to React

Demo

Code: https://github.com/robquick/chat-demo-react

Page 20: Introduction to React

Demo

https://brownbag-hsg.firebaseapp.com/

Page 21: Introduction to React

What else do we get by being decoupled from the

DOM?

Page 22: Introduction to React

Server-Side Rendering

Page 23: Introduction to React

Isomorphic JavaScript

Page 24: Introduction to React

Could we target something besides the DOM?

Page 25: Introduction to React

React Native

Page 26: Introduction to React

Source: https://facebook.github.io/react-native/

Page 27: Introduction to React

Source: https://facebook.github.io/react-native/

Page 28: Introduction to React

What React Isn’t

• Library, not a framework• Doesn’t tell you how to fetch data.• Doesn’t tell you how to push state changes

back to the server.• Doesn’t help you route from a url to a specific

component• Doesn’t provide you tooling for packaging or

deploying your application.

Page 29: Introduction to React

Questions?