React Native — Webnesday #9

13e697fec58c64352ac63984db062cdf?s=47 Robert Vogt
November 09, 2016

React Native — Webnesday #9

Slides for my talk about React Native at Webnesday #9 in St. Gallen.

13e697fec58c64352ac63984db062cdf?s=128

Robert Vogt

November 09, 2016
Tweet

Transcript

  1. 4.
  2. 5.

    $str = '<ul>'; foreach ($talks as $talk) { $str +=

    '<li>' . $talk->name . '</ li>'; } $str += '</ul>'; 1. Facebook in 2004 (PHP)
  3. 6.
  4. 9.

    «Welp, I’m going to take XHP to the browser within

    six months.» — Jordan Walke, Facebook / ReactJS
  5. 10.
  6. 11.

    var content = ( <TalkList>{talks.map(talk => <Talk talk={talk} /> )}

    </TalkList> ); 4. Facebook in 2013 (ReactJS)
  7. 13.

    function f(name) { var div = document.createElement('div'); var p =

    document.createElement('p'); p.textContent = 'Hello ' + name ? name : 'World'; div.appendChild(p); return div; } 
 var node = f('Webnesday'); document.getElementById('my- app').replaceWith(node);
  8. 14.
  9. 16.

    $(document).on('message.new', () => { let $count = $('.notifications__count'); let currentCount

    = parseInt($count.text(), 10); $count.text(++currentCount); }); 2. jQuery (Imperative)
  10. 17.

    const state = { unread: 1, messages: [{ id: 43,

    body: 'Hallo!', sender: 'Alice' }, { id: 42, body: 'Hoi :)', sender: 'Bob' }] }; 1. ReactJS (Declarative)
  11. 18.

    class TalkList extends React.Component { render () { return (

    <ul className='talk-list'> {props.messages.map((message) => ( <li>{message.sender} says: {message.body}</li> )} </ul> ); } }
 <TalkList messages={state.message} /> 2. ReactJS (Declarative)
  12. 19.

    class Counter extends React.Component { render () { const {

    count } = this.props; return ( <span className='counter'>{count}</span> ); } }
 <Counter count={state.unread} /> 3. ReactJS (Declarative)
  13. 20.

    const state = { unread: 2, messages: [{ id: 44,

    body: 'Wie gehts!', sender: 'Alice' }, { id: 43, body: 'Hallo!', sender: Alice' }] }; 4. ReactJS (Declarative)
  14. 24.

    class Hello extends React.Component { constructor(props) { super(props); this.state =

    { name: 'World' }; } render() { return ( <div className="hello"> <input ref={(c) => this._input = c} type="text" placeholder="Your Name" onChange={() => this.setState({ name: this._input.value })} /> <p>Hello {this.state.name}!</p> </div> ); } }
  15. 25.

    class Hello extends React.Component { constructor(props) { super(props); this.state =

    { name: 'World' }; } render() { return ( <View> <TextInput ref={(c) => this._input = c} placeholder="Your Name" onChange={() => this.setState({ name: this._input.value })} />
 <Text>Hello {this.state.name}!</Text> </View> ); } }
  16. 27.

    Components ActivityIndicator Button DatePickerIOS DrawerLayoutAndroid Image ListView MapView Modal Navigator

    Picker ProgressBarAndroid ProgressViewIOS RefreshControl ScrollView Slider SnapshotViewIOS StatusBar Switch TabBarIOS Text TextInput TouchableHighlight TouchableNativeFeedback TouchableOpacity TouchableWithoutFeedback View WebView APIS Alert Animated AppState AsyncStorage BackAndroid CameraRoll Clipboard Dimensions Geolocation ImageEditor ImageStore Keyboard Linking NetInfo PanResponder PushNotificationIOS Settings StyleSheet ToastAndroid Vibration
  17. 28.

    React Native Community Quality code from the React Native Community

    github.com/react-native-community react-native-svg react-native-elements react-native-blur react-native-tab-view react-native-video react-native-navbar react-native-side-menu
  18. 29.

    JS Runtime React Native
 JS API Custom App Code Android

    SDK Custom View Manager iOS SDK RN Bridge
  19. 30.

    Native Bridge JavaScript 1 2 3 4 5 6 8

    7 Event (touch, timer, networks, …) Collect data and notify JS Serialized payload Process event Call native methods Update UI if needed Process commands Serialized response
  20. 31.
  21. 32.

    $ brew install node $ brew install watchman $ npm

    install -g react-native Xcode AND/OR Gradle + Android Emulator
  22. 33.

    ! A Word Of Warning Fun on OS X macOS,

    not so much on Linux / Windows.
  23. 34.

    .babelrc android index.android.j s index.ios.js ios node_modules package.json src !""

    app.js $ react-native init WebnesdayApp $ cd WebnesdayApp $ react-native run-ios
  24. 35.