I'm working on react-native (Android) where I'm using redux-form 6.1.1.
One weird behaviour I've notice i.e redux-form doesn't perform validation when I remove focus(blur) from input field, however on submit validation is working as intended.
Please guide me here. Below is my code.
Text field component
<TextInput
keyboardType={ textType ? textType : 'default' }
onChangeText={ (val) => onChange(val) }
value={ value }
underlineColorAndroid="transparent"
style={ styleInput }
{...this.props}
/>
{/* Error message */}
<View>
{
touched && error ?
<Text>{error}</Text>
: null
}
</View>
Implementation of this Text field component as below
<Field
component={TextField}
name="phoneNumber"
placeholder="Mobile Number"
styleInput={styles.inputs}
styleInputWrap={styles.inputView}
/>
validate function
function validate(values) {
const err = {};
// common function for phone number validation
validatePhoneNumber(err, 'phoneNumber', values.phoneNumber);
return err;
}
Note: I observe that from touched && error condition error contains required error message but touched remains false even after switch/focus to another input field. As soon as I hit the submit button touched flag set to true.