Skip to content

Latest commit

 

History

History
138 lines (89 loc) · 2.49 KB

react-native.md

File metadata and controls

138 lines (89 loc) · 2.49 KB

React Native?

  • Build mobile apps using JavaScript
  • Facebook Open Source
  • Learn Once, Write Anywhere

Misconception

Does the JS compile to native code? No.



JavaScript ➡️ Bridge ➡️ Native code

React Native in Action (iOS)

import React from 'react';
import { AppRegistry, Button, Text, View } from 'react-native';

const Counter = ({ value }) => (
  <Text>State value is: {value}</Text>
);

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = { value: 42 };
  }

  handleOnClick = () => {
    this.setState(prevState => ({ value: prevState.value + 1 }));
  }

  render() {
    return (
      <View style={{ fontSize: '1.2em', margin: '1em' }}>
        <Counter value={this.state.value} />

        <Button onPress={this.handleOnClick} title="INCREMENT" />
      </View>
    );
  }
}

AppRegistry.registerComponent('App', () => App);

React Native in Action (Android)

import React from 'react';
import { AppRegistry, Button, Text, View } from 'react-native';

const Counter = ({ value }) => (
  <Text>State value is: {value}</Text>
);

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = { value: 42 };
  }

  handleOnClick = () => {
    this.setState(prevState => ({ value: prevState.value + 1 }));
  }

  render() {
    return (
      <View style={{ fontSize: '1.2em', margin: '1em' }}>
        <Counter value={this.state.value} />

        <Button onPress={this.handleOnClick} title="INCREMENT" />
      </View>
    );
  }
}

AppRegistry.registerComponent('App', () => App);

A React Native application is a real mobile application.

Xcode View Hierarchy

Who?

What else?

Remember the similar slide about React? 😎

+

A service by Microsoft to automatically push (OTA) updates to your mobile applications.

Skip the submission to Google Play/App Store 🚀

Developer Experience

  • Debugger in Chrome
  • Fast feedback loop
  • Live/Hot reload is ❤️❤️❤️

🔥🔥🔥