File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ import { compose , withProps } from "recompose" ;
2+ import { connect } from "formik" ;
3+ import withInputTypeProps from "./withInputTypeProps" ;
4+ import withFormikControl from "./withFormikControl" ;
5+
6+ const handleTextInput = compose (
7+ withFormikControl ,
8+ withInputTypeProps ,
9+ connect ,
10+ withProps (
11+ ( {
12+ formik : { isSubmitting } ,
13+ setFieldValue,
14+ setFieldTouched,
15+ onChangeText,
16+ onBlur
17+ } ) => ( {
18+ onChangeText : text => {
19+ setFieldValue ( text ) ;
20+ if ( onChangeText ) onChangeText ( text ) ;
21+ } ,
22+ onBlur : ( ) => {
23+ // validate onBlur only while not submitting
24+ // this prevents validating twice in succession when clicking 'done' on keyboard - first onSubmitEditing, then onBlur
25+ setFieldTouched ( true , ! isSubmitting ) ;
26+ if ( onBlur ) onBlur ( ) ;
27+ }
28+ } )
29+ )
30+ ) ;
31+
32+ export default handleTextInput ;
You can’t perform that action at this time.
0 commit comments