@@ -60,6 +60,9 @@ class TextEventsExample extends React.Component<{}, $FlowFixMeState> {
6060 onChange = { event =>
6161 this . updateText ( 'onChange text: ' + event . nativeEvent . text )
6262 }
63+ onTextInput = { event =>
64+ this . updateText ( 'onTextInput: ' + JSON . stringify ( event . nativeEvent ) )
65+ }
6366 onEndEditing = { event =>
6467 this . updateText ( 'onEndEditing text: ' + event . nativeEvent . text )
6568 }
@@ -489,6 +492,47 @@ class AutogrowingTextInputExample extends React.Component<
489492 }
490493}
491494
495+ class ControlledResetExample extends React . Component <
496+ $FlowFixMeProps ,
497+ $FlowFixMeState ,
498+ > {
499+ constructor ( props ) {
500+ super ( props ) ;
501+ this . state = {
502+ text : '' ,
503+ keys : '' ,
504+ } ;
505+ }
506+
507+ render ( ) {
508+ return (
509+ < View style = { styles . container } >
510+ < TextInput
511+ style = { styles . default }
512+ value = { this . state . text }
513+ onChangeText = { this . onChangeText }
514+ onKeyPress = { this . onKeyPress }
515+ />
516+ < Button title = "Reset" onPress = { this . onReset } />
517+ < Text > Text: { this . state . text } </ Text >
518+ < Text > Keys: { this . state . keys } </ Text >
519+ </ View >
520+ ) ;
521+ }
522+
523+ onChangeText = ( text : string ) => {
524+ this . setState ( { text } ) ;
525+ } ;
526+
527+ onKeyPress = ( { nativeEvent} : Object ) = > {
528+ this . setState ( { keys : this . state . keys + nativeEvent . key + ', ' } ) ;
529+ } ;
530+
531+ onReset = ( ) = > {
532+ this . setState ( { text : '' , keys : '' } ) ;
533+ } ;
534+ }
535+
492536const styles = StyleSheet . create ( {
493537 default : {
494538 borderWidth : StyleSheet . hairlineWidth ,
@@ -1104,4 +1148,10 @@ exports.examples = [
11041148 ) ;
11051149 } ,
11061150 } ,
1151+ {
1152+ title : 'Controlled reset' ,
1153+ render : function ( ) {
1154+ return < ControlledResetExample /> ;
1155+ } ,
1156+ } ,
11071157] ;
0 commit comments