Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {
- AppRegistry,
- StyleSheet,
- Text,
- View,
- TextInput,
- TouchableOpacity,
- Navigator,
- TouchableHighlight
- } from 'react-native';
- export default class calu extends Component {
- constructor(props){
- super(props);
- this.state={f2:null, height:null,result:0};
- this.compute=this.compute.bind(this);
- }
- compute(){
- console.log('pressed');
- let f1=(this.state.f1);
- let f2=parseInt(this.state.f2);
- this.setState({result: f1 + f2 });
- }
- render() {
- return (
- <View>
- <TextInput
- keyboardType='numeric' onChangeText={(text) => this.setState({f1: parseInt(text)})} placeholder='enter second number' />
- <TextInput
- keyboardType='numeric' onChangeText={(text) => this.setState({f2: parseInt(text)})} placeholder='enter second number' />
- <Text> result: {this.state.result.toFixed(2)} </Text>
- <TouchableOpacity
- onPress={this.compute}>
- <Text> compute </Text>
- </TouchableOpacity>
- </View>
- );
- }
- }
- AppRegistry.registerComponent('calu', () => calu);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement