2016-04-30 20 views
1

Ich verwende https://github.com/gcanti/tcomb-form-native & hier ist der Code-Snippetref Zugriff mit dem Rückruf onFocus bei der Verwendung von tcomb-Form-native

_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} 
        /> 

console.log druckt Objekt {}, wenn es um Scroll beziehen sollte, nicht sicher, was ich vermisse. Und hier ist der Code, der die Form richtet sich

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'); 
     } 
    } 
} 

}; 

Antwort

0

ref Attribut ein Rückruf und per react-native documentation alles, was ich tun müssen, um eine Referenz zu speichern, wie so

<ScrollView style={styles.container} ref={(ref) => this.myScrollView = ref}>