React nativeで Form の 値を取得してconsole.logする方法

ステートとかで状態維持しないバージョン。まずはフォームはこんな感じ。

<Form>

  <TextInput
  style={{height: 40}}
  placeholder="userName"
  onChangeText={(text) => this.userName = text}
  />

  <TextInput
  style={{height: 40}}
  placeholder="Password"
  onChangeText={(text) => this.Password = text}
  />


  <Button 
  title="Sign in!" 
  onPress={this._signInAsync} 
  />

  </Form>

 

参考

https://stackoverflow.com/questions/32913338/react-native-get-textinput-value/53878044#53878044

藤沢瞭介(Ryosuke Hujisawa)
  • りょすけと申します。18歳からプログラミングをはじめ、今はフロントエンドでReactを書いたり、AIの勉強を頑張っています。off.tokyoでは、ハイテクやガジェット、それからプログラミングに関する情報まで、エンジニアに役立つ情報を日々発信しています!

未整理記事

コメントする

メールアドレスが公開されることはありません。 が付いている欄は必須項目です