0

Hello I am using a floating label (MKTextField) in React native app. I want to know how to get the text from it. I tried to look online but could not find it.

Using react native material kit "react-native-material-kit": "^0.5.1",

could you please suggest

Thanks R

<TextfieldWithFloatingLabel_Card ref="tiNumber"/>

const TextfieldWithFloatingLabel_Card = MKTextField.textfieldWithFloatingLabel()
.withPlaceholder('Last 4 digits of your dopay card')
.withStyle(styles.textfieldWithFloatingLabel)
.withTextInputStyle({flex: 1})
.withFloatingLabelFont({
  fontSize: 12,
  fontWeight: '200',
  color: colors.primaryColor
})
.withKeyboardType('numeric')
.build();
BRDroid
  • 3,920
  • 8
  • 65
  • 143

1 Answers1

1

There are multiple props for getting text. consider below code

<TextfieldWithFloatingLabel_Card ref="tiNumber"/>

const TextfieldWithFloatingLabel_Card = MKTextField.textfieldWithFloatingLabel()
.withPlaceholder('Last 4 digits of your dopay card')
.withStyle(styles.textfieldWithFloatingLabel)
.withTextInputStyle({flex: 1})
.withFloatingLabelFont({
  fontSize: 12,
  fontWeight: '200',
  color: colors.primaryColor
})
.withKeyboardType('numeric')
.withOnEndEditing((e) => console.log('EndEditing', e.nativeEvent.text))
.withOnSubmitEditing((e) => console.log('SubmitEditing', e.nativeEvent.text))
.withOnTextChange((e) => console.log('TextChange', e))
.withOnChangeText((e) => console.log('ChangeText', e))
.build();
Vinayak B
  • 4,430
  • 4
  • 28
  • 58
  • Thank you @vinayak for that. One question I have is, I have placed `TextfieldWithFloatingLabel_Card ` outside my class and I want to set the state from it but I cannot access state from outside the class any thoughts on how to set the state from outsude the class – BRDroid Oct 16 '18 at 14:06
  • You can't set state outside of the class unless you should pass the setState method as a argument..but I don't know if it works or not.I didn't try it – Vinayak B Oct 16 '18 at 15:50
  • 1
    Okay thank you I will get to it. thank you for your help for the initial question – BRDroid Oct 16 '18 at 15:51