Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react';
- import {Text, StyleSheet, View, TextInput} from 'react-native';
- class Barang extends Component {
- constructor(props) {
- super(props);
- this.state = {
- namaBarang: '',
- jumlahBarang: ''
- };
- }
- handleInputNamaBarang = (event) => {
- this.setState({namaBarang:event})
- }
- handleInputJumlahBarang = (event) => {
- this.setState({jumlahBarang:event})
- }
- render() {
- return (
- <View style={styles.container}>
- <Text>Tugas React Native 2</Text>
- {this.namaBarang()}
- {this.jumlahBarang()}
- </View>
- );
- }
- }
- namaBarang = () => {
- return (
- <View>
- <Text>Nama Barang: {this.state.namaBarang}</Text>
- <TextInput
- onChangeText={this.handleInputNamaBarang}
- placeholder='Masukkan Nama Barang'
- value={this.state.namaBarang}/>
- </View>
- )
- }
- jumlahBarang = () => {
- return (
- <View>
- <Text>Jumlah Barang: {this.state.jumlahBarang}</Text>
- <TextInput
- onChangeText={this.handleInputJumlahBarang}
- placeholder='Masukkan Jumlah Barang'
- value={this.state.jumlahBarang}
- keyboardType='numeric'/>
- </View>
- )
- }
- export default Barang
- const styles = StyleSheet.create({
- container: {
- alignItems: 'center',
- justifyContent: 'center',
- },
- title: {
- textAlign: 'center',
- fontSize: 15,
- fontWeight: 'bold'
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement