SHARE
TWEET

barang.js

yosadade Feb 21st, 2020 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, {Component} from 'react';
  2. import {Text, StyleSheet, View, TextInput} from 'react-native';
  3.  
  4. class Barang extends Component {
  5.   constructor(props) {
  6.     super(props);
  7.     this.state = {
  8.       namaBarang: '',
  9.       jumlahBarang: ''
  10.     };
  11. }
  12.  
  13. handleInputNamaBarang = (event) => {
  14.   this.setState({namaBarang:event})
  15. }
  16.  
  17. handleInputJumlahBarang = (event) => {
  18.   this.setState({jumlahBarang:event})
  19. }
  20.  
  21.   render() {
  22.     return (
  23.       <View style={styles.container}>
  24.         <Text>Tugas React Native 2</Text>
  25.         {this.namaBarang()}
  26.         {this.jumlahBarang()}
  27.       </View>
  28.     );
  29.   }
  30. }
  31.  
  32. namaBarang = () => {
  33.     return (
  34.         <View>
  35.             <Text>Nama Barang: {this.state.namaBarang}</Text>
  36.             <TextInput
  37.             onChangeText={this.handleInputNamaBarang}
  38.             placeholder='Masukkan Nama Barang'
  39.             value={this.state.namaBarang}/>
  40.         </View>
  41.     )
  42. }
  43.  
  44. jumlahBarang = () => {
  45.     return (
  46.         <View>
  47.             <Text>Jumlah Barang: {this.state.jumlahBarang}</Text>
  48.             <TextInput
  49.             onChangeText={this.handleInputJumlahBarang}
  50.             placeholder='Masukkan Jumlah Barang'
  51.             value={this.state.jumlahBarang}
  52.             keyboardType='numeric'/>
  53.         </View>
  54.     )
  55. }
  56.  
  57. export default Barang
  58.  
  59. const styles = StyleSheet.create({
  60.     container: {
  61.         alignItems: 'center',
  62.         justifyContent: 'center',
  63.     },
  64.     title: {
  65.         textAlign: 'center',
  66.         fontSize: 15,
  67.         fontWeight: 'bold'
  68.     }
  69. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top