2016-04-30 3 views
1

を使用しながらのonFocusコールバックとREFにアクセスここでコードのスニペットは、それがscrollViewを参照する必要がある場合にconsole.logプリントが} {オブジェクト私は<a href="https://github.com/gcanti/tcomb-form-native" rel="nofollow">https://github.com/gcanti/tcomb-form-native</a> &を使用していtcomb状ネイティブ

_renderScene(route, navigator) { 
     var Cook_time = { 
     onFocus:() => { 
      console.log('cook time has focus'); 
      console.log(this.refs); 
     }, 
    }; 

    options.fields['Cook_time'] = Cook_time; 


    return (
     <View style={{ flex: 1 }}> 
      <ScrollView style={styles.container} ref="scrollView"> 

       <Form 
        ref="form" 
        type={Recipe} 
        options={options} 
        onChange={this.onChange} 
        onFocus={this.onChange} 
        /> 

ありません私は何が欠けているのか確かめてください。そして、ここでフォーム自体

var Recipe = t.struct({ 
Recipe_name: t.String, 
yield: t.maybe(t.String), 
Prep_time: t.maybe(t.String), 
Cook_time: t.maybe(t.String), 
source: t.maybe(t.String), 
}) 

var options = { 
fields: { 
    yield: { 
     label: 'Yield', 
    }, 
    Prep_time: { 
     label: 'Preparation time', 
    }, 

    source: { 
     label: 'Source', 
     placeholder: 'family, friends, website ...', 
     onFocus: function() { 
      console.log('source has focus'); 
     } 
    } 
} 

}; 

答えて

0

REF属性がコールバックされ、react-native documentation ごとに私が行うために必要なすべてがそう

<ScrollView style={styles.container} ref={(ref) => this.myScrollView = ref}> 
などの基準を保存しているが設定されたコードです
関連する問題