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

React Nativeで開発するマルチプラットフォームアプリ

React Nativeで開発するマルチプラットフォームアプリ

iOSDC 2017 Reject Conference

Masayuki Iwai

October 13, 2017
Tweet

More Decks by Masayuki Iwai

Other Decks in Technology

Transcript

  1. 3FBDU w 'BDFCPPL੡ͷ+BWB4DSJQUϥΠϒϥϦ
 ʢLʣ
 IUUQTSFBDUKTPSH w ίϯϙʔωϯτϕʔεͰ6*ʢϏϡʔʣΛߏங w +49εΫϦϓτதʹ%0.ͰϏϡʔΛهड़ w

    QSPQTͱTUBUFʹج͍ͮͯSFOEFSؔ਺Ͱ ϏϡʔΛඳը w QSPQT΍TUBUF͕มԽ͢Δͱɺࣗಈతʹ Ϗϡʔͷࠩ෼ͷΈ͕࠶ඳը͞ΕΔ import React from 'react' class App extends React.Component { state = { label: 'It works!', } render() { return ( <div className="container"> <div className="content"> <h1 className="name"> {this.props.name} </h1> <p className="label"> {this.state.label} </p> </div> </div> ) } }
  2. 3FEVY w ঢ়ଶ؅ཧͷͨΊͷ+BWB4DSJQU
 ϥΠϒϥϦʢLʣ
 IUUQSFEVYKTPSH w σʔλͷྲྀΕΛํ޲ʹ͠ɺ
 ঢ়ଶͷอ࣋ͱߋ৽Λू໿
 ˠෳࡶͳΞϓϦέʔγϣϯͷ඼࣭ͱ
 ɹϝϯςφϯεੑͷ޲্

    w 4XJGUքʹ͓͍ͯ΋3F4XJGUͱ࣮ͯ͠ ૷͞ΕΔͳͲɺ஫໨ͷΞʔΩςΫνϟ 4UPSF 6*
 ʢϏϡʔʣ "DUJPO 3FEVDFS %JTQBUDI ߋ৽ Πϕϯτ ߋ৽͞Εͨ4UBUF 4UBUF
 ʢঢ়ଶʣ
  3. 3FBDU 3FEVY w SFBDUSFEVY3FEVYͷ3FBDUόΠϯσΟϯάʢެࣜʣ
 IUUQTHJUIVCDPNSFBDUKTSFBDUSFEVY w 3FBDU͸ίϯϙʔωϯτͷঢ়ଶʢQSPQTͱTUBUFʣʹΑͬͯϏϡʔΛඳը͢Δ
 ͷͰɺ૬ੑ͕ྑ͍ w $POUBJOFS$PNQPOFOUͱ1SFTFOUBUJPOBM$PNQPOFOU


    $POUBJOFS$PNQPOFOU3FEVYͱ࿈ܞ͢Δ
 ʢ4UPSF͔Β4UBUFΛಘͨΓɺ"DUJPOΛEJTQBUDI͢Δʣ
 1SFTFOUBUJPOBM$PNQPOFOU௚઀3FEVYʹؔ༩ͤͣɺQSPQTܦ༝ͰͷΈ
 σʔλΛड͚औΔʢϏϡʔͷඳըʹઐ೦ʣ
  4. 3FBDU/BUJWF import React from 'react' class App extends React.Component {

    state = { label: 'It works!', } render() { return ( <div className="container"> <div className="content"> <h1 className="name"> {this.props.name} </h1> <p className="label"> {this.state.label} </p> </div> </div> ) } } import React from 'react' import { ScrollView, View, Text } from 'react- native' class App extends React.Component { state = { label: 'It works!', } render() { return ( <ScrollView style={styles.container}> <View style={styles.content}> <Text style={styles.name}> {this.props.name} </Text> <Text style={styles.label}> {this.state.label} </Text> </View> </ScrollView> ) } }
  5. ίϯϙʔωϯτϕʔε͕ྑ͍ w ίϯϙʔωϯτ୯ҐͰςετͰ͖Δ w ։ൃ͕ਐΜͰෳࡶʹͳͬͨ෦෼Λ
 ޙ͔ΒͰ΋෼཭͠΍͍͢ w ϑΝΠϧ໊ͰϓϥοτϑΥʔϜ͝ͱ ʹίϯϙʔωϯτΛಡΈ෼͚ΒΕΔ
 ˠʢྫʣ'PPJPTKTͱ'PPBOESPJEKT

    import React from 'react' import { ScrollView, View, Text } from 'react-native' class App extends React.Component { state = { label: 'It works!', } render() { return ( <ScrollView style={styles.container}> <View style={styles.content}> <Text style={styles.name}> {this.props.name} </Text> <Text style={styles.label}> {this.state.label} </Text> </View> </ScrollView> ) } }
  6. ίϯϙʔωϯτϕʔε͕ྑ͍ w ίϯϙʔωϯτ୯ҐͰςετͰ͖Δ w ։ൃ͕ਐΜͰෳࡶʹͳͬͨ෦෼Λ
 ޙ͔ΒͰ΋෼཭͠΍͍͢ w ϑΝΠϧ໊ͰϓϥοτϑΥʔϜ͝ͱ ʹίϯϙʔωϯτΛಡΈ෼͚ΒΕΔ
 ˠʢྫʣ'PPJPTKTͱ'PPBOESPJEKT

    import React from 'react' import { ScrollView, View, Text } from 'react-native' class App extends React.Component { state = { label: 'It works!', } render() { return ( <ScrollView style={styles.container}> <View style={styles.content}> <Text style={styles.name}> {this.props.name} </Text> <Text style={styles.label}> {this.state.label} </Text> </View> </ScrollView> ) } }
  7. ίϯϙʔωϯτϕʔε͕ྑ͍ w ίϯϙʔωϯτ୯ҐͰςετͰ͖Δ w ։ൃ͕ਐΜͰෳࡶʹͳͬͨ෦෼Λ
 ޙ͔ΒͰ΋෼཭͠΍͍͢ w ϑΝΠϧ໊ͰϓϥοτϑΥʔϜ͝ͱ ʹίϯϙʔωϯτΛಡΈ෼͚ΒΕΔ
 ˠʢྫʣ'PPJPTKTͱ'PPBOESPJEKT

    import React from 'react' import { ScrollView } from 'react-native' import ContentView from 'ContentView' class App extends React.Component { state = { label: 'It works!', } render() { return ( <ScrollView style={styles.container}> <ContentView style={styles.content} name={this.props.name} label={this.state.label} /> </ScrollView> ) } }
  8. 'MFYCPYελΠϧγʔτͰࢥ͍௨ΓͷϨΠΞ΢τ w 3FBDU/BUJWFͷϏϡʔͷϨΠΞ΢τ͸
 'MFYCPYʹجͮ͘ w "VUP-BZPVUͱҧ͍ɺ8FCతͳΞϓϩʔ νͰϨεϙϯγϒͳσβΠϯ͕Մೳ w Ϗϡʔͷଐੑ͸ελΠϧγʔτͰهड़
 ϨΠΞ΢τʹؔ͢Δଐੑ


    ʢqFY XJEUI IFJHIU NBSHJOFUDʣ
 ࢹ֮తͳଐੑ
 ʢCPSEFS8JEUI PQBDJUZFUDʣ const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: '#f5fcff', }, label: { fontSize: 30, fontWeight: 'bold', color: '#262729', }, box: { justifyContent: 'center', alignItems: 'center', width: 100, height: 100, backgroundColor: '#f1f3f4', }, });
  9. +BWB4DSJQUΏ͑ͷͭΒΈ w ܕͷͳ͍ੈք
 ͱ͸͍͑5ZQF4DSJQU΍'MPX͕͋Δ
 KTϑΝΠϧͷ··ΞϊςʔγϣϯΛ௥ՃͰ͖ͯ
 ੩తʹνΣοΫͰ͖Δ'MPX͕͍͍ײ͡
 όʔδϣϯͷ૊Έ߹ΘͤʹΑͬͯΤϥʔʹ
 ͳͬͨΓͳΒͳ͔ͬͨΓ͢Δ͜ͱ΋ʜ w ࣗ༝౓͕ߴ͍͗ͯ͢ΖΜͳελΠϧͰॻ͚

    ͪΌ͏
 ։ൃϝϯόʔ͕૿͑ͨͱ͖͕৺഑
 "JSCOC͕ެ։͍ͯ͠ΔελΠϧΨΠυΛ
 ϕʔεʹFTMJOUΛઃఆ
 IUUQTHJUIVCDPNBJSCOCKBWBTDSJQU import React from 'react' import { ScrollView } from 'react-native' import ContentView from 'ContentView' class App extends React.Component { state = { label: 10000, } render() { return ( <ScrollView style={styles.container}> <ContentView style={styles.content} name={this.props.name} label={this.state.label} /> </ScrollView> ) } }
  10. +BWB4DSJQUΏ͑ͷͭΒΈ w ܕͷͳ͍ੈք
 ͱ͸͍͑5ZQF4DSJQU΍'MPX͕͋Δ
 KTϑΝΠϧͷ··ΞϊςʔγϣϯΛ௥ՃͰ͖ͯ
 ੩తʹνΣοΫͰ͖Δ'MPX͕͍͍ײ͡
 όʔδϣϯͷ૊Έ߹ΘͤʹΑͬͯΤϥʔʹ
 ͳͬͨΓͳΒͳ͔ͬͨΓ͢Δ͜ͱ΋ʜ w ࣗ༝౓͕ߴ͍͗ͯ͢ΖΜͳελΠϧͰॻ͚

    ͪΌ͏
 ։ൃϝϯόʔ͕૿͑ͨͱ͖͕৺഑
 "JSCOC͕ެ։͍ͯ͠ΔελΠϧΨΠυΛ
 ϕʔεʹFTMJOUΛઃఆ
 IUUQTHJUIVCDPNBJSCOCKBWBTDSJQU import React from 'react' import { ScrollView } from 'react-native' import ContentView from 'ContentView' type Props = { name: string, // stringʢnull΍undefined͸ڐՄ͞Εͳ͍ʣ }; type State = { label: ?string, // stringʢnullڐՄʣ }; class App extends React.Component<Props, State> { state = { label: 10000, // ERROR!! } render(): React.Node { return ( <ScrollView style={styles.container}> <ContentView style={styles.content} name={this.props.name} label={this.state.label} /> </ScrollView> ) } }