См. Пример ниже, надеюсь, это поможет вам.
import React, { Component } from 'react';
import { StyleSheet, View, TextInput, Button } from 'react-native';
class App extends Component {
state = {
name: '',
};
onChangeName = value => {
this.setState({
name: value,
});
};
checkUserDetails = () => {
//
};
render() {
const { name} = this.state;
const { scrollview, inputStyle } = styles;
return (
<View style={styles.scrollview}>
<View style={{ width: '90%', alignSelf: 'center' }}>
<TextInput
style={inputStyle}
placeholder={` name`}
placeholderTextColor={'#ED3C20'}
onChangeText={this.onChangeName}
value={name}
/>
<Button
disabled={!this.state.name ? true : false}
title="submit"
buttonHandler={this.checkUserDetails}
/>
</View>
</View>
);
}
}
const styles = StyleSheet.create({
scrollview: {
flex: 1,
justifyContent: 'center',
},
inputStyle: {
height: 45,
borderWidth: 2,
borderColor: 'gray',
marginBottom: 5,
textAlign: 'auto',
},
});
export default App;
Не стесняйтесь сомнений.