0

In React Native 16.

Get input value

<Input
 ...
 onChange={event => getValue(event)}
 />

Output value

const getValue = event => {
   console.log(event.nativeEvent.text);
 };

2 Answers 2

5

The Input component from react-native-elements is basically rendering the TextInput component. So you can use onChangeText instead of onChange like

import React, { Component } from 'react';
import { Input } from 'react-native-elements';

export default function UselessTextInput() {
  const [value, onChangeText] = React.useState('Useless Placeholder');

  return (
    <Input
      onChangeText={text => onChangeText(text)}
      value={value}
    />
  );
}

Hope this helps

Sign up to request clarification or add additional context in comments.

1 Comment

Nice syntax !!. Great
0

Set value to the state.

const getValue = event => {
   this. setState({text: event.nativeEvent.text});
 };

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.