Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


Calculadora Basica en React, Ejercicios de Programación Javascript

Calculadora Básica en React Native en Expo Snack

Tipo: Ejercicios

2020/2021

Subido el 12/02/2022

sam-martinez-l32
sam-martinez-l32 🇲🇽

3 documentos

1 / 9

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
import React, { Component } from 'react';
import { View, Text, StyleSheet, Button } from 'react-native';
export default class calculadora extends Component {
constructor(props) {
super(props);
this.state = {
resultado: '',
temp: '',
bandera: '0',
};
}
render() {
const clickbtn1 = () => {
this.setState({resultado: this.state.resultado+1});
};
const clickbtn2 = () => {
this.setState({resultado: this.state.resultado+2});
};
const clickbtn3 = () => {
this.setState({resultado: this.state.resultado+3});
};
const clickbtn4 = () => {
this.setState({resultado: this.state.resultado+4});
};
const clickbtn5 = () => {
this.setState({resultado: this.state.resultado+5});
};
pf3
pf4
pf5
pf8
pf9

Vista previa parcial del texto

¡Descarga Calculadora Basica en React y más Ejercicios en PDF de Programación Javascript solo en Docsity!

import React, { Component } from 'react'; import { View, Text, StyleSheet, Button } from 'react-native'; export default class calculadora extends Component { constructor(props) { super(props); this.state = { resultado: '', temp: '', bandera: '0', }; } render() { const clickbtn1 = () => { this.setState({resultado: this.state.resultado+1}); }; const clickbtn2 = () => { this.setState({resultado: this.state.resultado+2}); }; const clickbtn3 = () => { this.setState({resultado: this.state.resultado+3}); }; const clickbtn4 = () => { this.setState({resultado: this.state.resultado+4}); }; const clickbtn5 = () => { this.setState({resultado: this.state.resultado+5}); };

const clickbtn6 = () => { this.setState({resultado: this.state.resultado+6}); }; const clickbtn7 = () => { this.setState({resultado: this.state.resultado+7}); }; const clickbtn8 = () => { this.setState({resultado: this.state.resultado+8}); }; const clickbtn9 = () => { this.setState({resultado: this.state.resultado+9}); }; const clickbtn0 = () => { this.setState({resultado: this.state.resultado+0}); }; const clickbtnsuma = () => { this.setState({temp: this.state.resultado}); this.setState({resultado:''}); this.setState({bandera: '1'}) }; const clickbtnresta = () => { this.setState({temp: this.state.resultado}); this.setState({resultado:''}); this.setState({bandera: '2'}) }; const clickbtnmult = () => { this.setState({temp: this.state.resultado}); this.setState({resultado:''}); this.setState({bandera: '3'})

return ( Calculadora <Text style={{fontSize:20, textAlign:"center", marginTop:5}}> {this.state.resultado}

height:50, width:50, marginLeft:230, marginTop:-50, }, btn4:{ height:50, width:50, marginLeft:50, marginTop:20, }, btn5:{ height:50, width:50, marginLeft:110, marginTop:-50, }, btn6:{ height:50, width:50, marginLeft:170, marginTop:-50, }, btnsuma:{ height:50, width:50, marginLeft:230, marginTop:-50, },

btn7:{ height:50, width:50, marginLeft:50, marginTop:20, }, btn8:{ height:50, width:50, marginLeft:110, marginTop:-50, }, btn9:{ height:50, width:50, marginLeft:170, marginTop:-50, }, btnresta:{ height:50, width:50, marginLeft:230, marginTop:-50, }, btn0:{ height:50, width:50, marginLeft:50, marginTop:20,