Professional Documents
Culture Documents
● Create a short video demo showing that the app is working then upload it to your
youtube channel then post the link here.
function addTogether() {
const newTotal = number1 + number2;
setTotal(newTotal);
document.getElementById("demo").innerHTML = "SUM: " + newTotal;
Alert.alert('Alert', 'SUM: ' + newTotal); // total has the old value in the render
}
return (
<View style={styles.container}>
<Text style={styles.txtcolor}>Welcome To my Page</Text>
<Text>Jopher F. Reyes</Text>
<TextInput
type="number"
placeholder="0"
value={number1}
onChangeText={v => {
setNumber1(Number.parseInt(v)); // Use parsed value from onChangeText
}}
/>
<TextInput
type="number"
placeholder="0"
value={number2}
onChange={e => {
setNumber2(Number.parseInt(e.nativeEvent.text)); // or get correct value from
nativeEvent onChange
}}
/>
<p id="demo"></p>
<Button onPress={addTogether} title="SUM" />
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'space-evenly',
},
image: {
width: 250,
height: 100,
},
input: {
width: 200,
borderColor: 'gray',
borderWidth: 1,
},
txtcolor: {
color: 'red',
},
});