Reputation: 1060
In React Native 16.
Get input value
<Input
...
onChange={event => getValue(event)}
/>
Output value
const getValue = event => {
console.log(event.nativeEvent.text);
};
Upvotes: 0
Views: 4516
Reputation: 2826
Set value to the state.
const getValue = event => {
this. setState({text: event.nativeEvent.text});
};
Upvotes: 0
Reputation: 1850
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
Upvotes: 5