george
george

Reputation: 41

on change text not working for imported component

so i created and imported a component that is text input. however, it is not setting the text on change. any ideas?

<Email onChangeText={(email) => setEmail(email)}/>
import React from 'react';
import {TextInput} from 'react-native';

function Email() {
  return (
    <TextInput
      label="Email"
      placeholder="Email"
      placeholderTextColor="black"
      style = {{ width: 310, padding:20, marginBottom:10, backgroundColor:"#ebecff", borderRadius:10 }}
    />
  );
}
export default Email;

Upvotes: 0

Views: 33

Answers (1)

Nooruddin Lakhani
Nooruddin Lakhani

Reputation: 6967

This might help

function Email(props) {
  return (
    <TextInput
      ...
      onChangeText={text => props.onChangeText(text)} // add this code
    />
  );
}

Upvotes: 1

Related Questions