/** * Copyright 2004-present Facebook. All Rights Reserved. * * @providesModule TextInputExample */ 'use strict'; var React = require('react-native'); var { Text, TextInput, View, StyleSheet, } = React; var WithLabel = React.createClass({ render: function() { return ( {this.props.label} {this.props.children} ); } }); var TextEventsExample = React.createClass({ getInitialState: function() { return { curText: '', prevText: '', }; }, updateText: function(text) { this.setState({ curText: text, prevText: this.state.curText, }); }, render: function() { return ( this.updateText('onFocus')} onBlur={() => this.updateText('onBlur')} onChange={(event) => this.updateText( 'onChange text: ' + event.nativeEvent.text )} onEndEditing={(event) => this.updateText( 'onEndEditing text: ' + event.nativeEvent.text )} onSubmitEditing={(event) => this.updateText( 'onSubmitEditing text: ' + event.nativeEvent.text )} style={styles.default} /> {this.state.curText}{'\n'} (prev: {this.state.prevText}) ); } }); var styles = StyleSheet.create({ page: { paddingBottom: 300, }, default: { height: 26, borderWidth: 0.5, borderColor: '#0f0f0f', padding: 4, flex: 1, fontSize: 13, }, multiline: { borderWidth: 0.5, borderColor: '#0f0f0f', flex: 1, fontSize: 13, height: 50, }, eventLabel: { margin: 3, fontSize: 12, }, labelContainer: { flexDirection: 'row', marginVertical: 2, flex: 1, }, label: { width: 80, justifyContent: 'flex-end', flexDirection: 'row', marginRight: 10, paddingTop: 2, }, }); exports.title = ''; exports.description = 'Single-line text inputs.'; exports.examples = [ { title: 'Auto-focus', render: function() { return ; } }, { title: 'Auto-capitalize', render: function() { return ( ); } }, { title: 'Auto-correct', render: function() { return ( ); } }, { title: 'Event handling', render: () => , }, { title: 'Colored input text', render: function() { return ( ); } }, { title: 'Clear button mode', render: function () { return ( ); } }, ];