0
Hello, I’m trying to give a setstate but when I run it returns me that is not a function
renderInput({ input, label, type, meta: { touched, error, warning } }) {
onChangeTextDestino = async (param) => {
try {
this.setState({strEmail: param})
Alert.alert(this.state.strEmail)
} catch (e) {
console.log("error", e)
}
}
return (
<View>
<Item error={error && touched} rounded style={styles.inputGrp}>
<Icon
active
name={input.name === "email" ? "mail" : "unlock"}
style={{ color: "#fff" }}
/>
<Input
ref={c => (this.textInput = c)}
placeholderTextColor="#FFF"
style={styles.input}
placeholder={input.name === "email" ? "Email" : "Senha"}
secureTextEntry={input.name === "password" ? true : false}
onChangeText={text => this.onChangeTextDestinos(text)}
{...input}
/>
{touched && error
? <Icon
active
style={styles.formErrorIcon}
onPress={() => this.textInput._root.clear()}
name="close"
/>
: <Text />}
</Item>
{touched && error
? <Text style={styles.formErrorText1}>
{error}
</Text>
: <Text style={styles.formErrorText2}>error here</Text>}
</View>
);
}
This component is called so :
<Field
name="email"
component={this.renderInput}
type="email"
validate={[email, required]}
/>
How do I pass that function to props?
component={this.renderInput}
Is this really the code? How are you exporting the methods? Are they separate files? Could you detail a little more
– JrD
The code is really this, in the main class we have Field, and we created the renderInput component to pass as parameter to that field...
– Gabriel Souza
Jrd, the real problem is here https://stackoverflow.com/questions/52556195/how-send-props-using-field-redux-form
– Gabriel Souza