/** * Copyright (c) 2015-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @flow * @providesModule TextInputExample */ 'use strict'; const Button = require('Button'); const InputAccessoryView = require('InputAccessoryView'); var React = require('react'); var ReactNative = require('react-native'); var { Text, TextInput, View, StyleSheet, Slider, Switch, } = ReactNative; class WithLabel extends React.Component<$FlowFixMeProps> { render() { return ( {this.props.label} {this.props.children} ); } } class TextEventsExample extends React.Component<{}, $FlowFixMeState> { state = { curText: '', prevText: '', prev2Text: '', prev3Text: '', }; updateText = (text) => { this.setState((state) => { return { curText: text, prevText: state.curText, prev2Text: state.prevText, prev3Text: state.prev2Text, }; }); }; render() { 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 )} onSelectionChange={(event) => this.updateText( 'onSelectionChange range: ' + event.nativeEvent.selection.start + ',' + event.nativeEvent.selection.end )} onKeyPress={(event) => { this.updateText('onKeyPress key: ' + event.nativeEvent.key); }} style={styles.default} /> {this.state.curText}{'\n'} (prev: {this.state.prevText}){'\n'} (prev2: {this.state.prev2Text}){'\n'} (prev3: {this.state.prev3Text}) ); } } class TextInputAccessoryViewExample extends React.Component<{}, *> { constructor(props) { super(props); this.state = {text: 'Placeholder Text'}; } render() { const inputAccessoryViewID = 'inputAccessoryView1'; return ( this.setState({text})} value={this.state.text} />