Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, {Component} from 'react';
- import {Text, View, Image} from 'react-native';
- class Janta extends Component {
- constructor(props){
- super(props);
- this.state={comida:props.comida};
- var comidas=['Pizza', 'Lasanha','Burger','Sopa','arroz'];
- setInterval(()=>{
- this.setState(previousState=>{
- var n = Math.floor(Math.random() * comidas.length);
- return {comida: comidas[n]};
- });
- },1000);
- }
- render() {
- return(
- <View style={{paddingTop:20}}>
- <Text style={{textAlign:'center', fontWeight:'bold', fontSize:20}}>Hoje você vai jantar: </Text>
- <Text style={{textAlign:'center', fontSize:20}}>{this.state.comida}</Text>
- </View>
- );
- }
- }
- export default class PrimeiroProjeto extends Component {
- render() {
- return (
- <View style={{paddingTop:20}}>
- <Janta comida='Bolacha'/>
- </View>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement