Upgrade to Pro — share decks privately, control downloads, hide ads and more …

React Native

React Native

Talk presented at GDG Juiz de Fora on 2015/10/07.

I presented the key concepts on React and React Native. Also did some live coding to create some components.

Sample code created during talk at https://github.com/marlonandrade/HearthstoneCompendium

Marlon Andrade

October 07, 2015
Tweet

More Decks by Marlon Andrade

Other Decks in Technology

Transcript

  1. – Facebook team “We built React to solve one problem:

    building large applications with data that changes over time.”
  2. Simple • Express how the app should look at any

    given point in time • React will manage all the UI updates when your data changes
  3. Declarative • When data changes, React knows to only update

    the changed parts • You doesn’t care how those changes are made
  4. Virtual DOM • Abstracts the DOM and give a simpler

    programming model and better performance • Minimizes the repaints focusing only on what has changed
  5. Data Flow • One-way reactive data flow • Much simpler

    then traditional data binding • Declarative
  6. • Start with a mock • Break the UI into

    a Component hierarchy • Build a static version in React • Identify the minimal representation of UI State • Identify where the state should live • Add inverse data flow
  7. [ {category: "Sporting Goods", price: "$49.99", stocked: true, name: "Football"},

    {category: "Sporting Goods", price: "$9.99", stocked: true, name: "Baseball"}, {category: "Sporting Goods", price: "$29.99", stocked: false, name: "Basketball"}, {category: "Electronics", price: "$99.99", stocked: true, name: "iPod Touch"}, {category: "Electronics", price: "$399.99", stocked: false, name: "iPhone 5"}, {category: "Electronics", price: "$199.99", stocked: true, name: "Nexus 7"} ];
  8. Build a static version in React • ignore API data,

    state and just render what you need • state vs props
  9. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  10. Identify the minimal representation of UI State • Questions to

    help find out which one is state • Passed from a parent via props? • Change over time? • Can be computed on any other state or prop?
  11. Identify the minimal representation of UI State • Questions to

    help find out which one is state • Passed from a parent via props? • Change over time? • Can be computed on any other state or prop?
  12. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  13. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  14. Identify the minimal representation of UI State • Questions to

    help find out which one is state • Passed from a parent via props? • Change over time? • Can be computed on any other state or prop?
  15. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  16. Identify the minimal representation of UI State • Questions to

    help find out which one is state • Passed from a parent via props? • Change over time? • Can be computed on any other state or prop?
  17. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  18. Identify the minimal representation of UI State • original product

    list • search text the user has entered • value of the checkbox • filtered list of products
  19. Identify where the state should live • identify every component

    that renders something based on that state • find a common owner component (single component above all the other in the hierarchy) • either the common owner or another component higher up should own the state • if you can’t find a component where it makes sense to own the state, create a new one simply for holding the state
  20. Add inverse data flow • create the inverse flow that

    allow the inner components to update the state • normally, implemented as props callbacks that allow the children to update the parent’s state
  21. Native components • standard platform components such as UITabBar on

    iOS or Navigation Drawer on Android • consistent look and feel with the rest of the platform ecosystem
  22. Asynchronous execution • bridge between JS and native platform is

    async • JS runs on the background • it makes apps fluid and responsive
  23. Flexbox and Styling • styling based on CSS, with a

    few properties allowed for each component • layout easily with Flexbox
  24. Extensible • easy to create app without writing a single

    line of native code • but, very ease to create your own modules or views and bridge / import into JS