SHARE
TWEET

Untitled

a guest Apr 22nd, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { View, Text, StyleSheet, Button } from 'react-native';
  3. import { StackActions, NavigationActions } from 'react-navigation';
  4. import { connect } from 'react-redux';
  5. import { trocarCor } from '../actions/CoresActions';
  6.  
  7. export class Tela1 extends Component {
  8.  
  9.     constructor(props) {
  10.         super(props);
  11.         this.state = {};
  12.  
  13.     this.acaoBotao = this.acaoBotao.bind(this);
  14.     }
  15.  
  16.   acaoBotao() {
  17.     this.props.trocarCor('vermelho');
  18.    
  19.     this.props.navigation.navigate('Tela2');
  20.   }
  21.  
  22.     render(){
  23.         return (
  24.             <View style={styles.container}>
  25.                 <Text>COR ATUAL: {this.props.cor}</Text>
  26.  
  27.         <Button onPress={this.acaoBotao} title="Trocar para Vermelho" />
  28.             </View>
  29.         );
  30.     }
  31. }
  32.  
  33. const styles = StyleSheet.create({
  34.     container:{
  35.         flex:1,
  36.         justifyContent:'center',
  37.         alignItems:'center'
  38.     }
  39. });
  40.  
  41. const mapStateToProps = (state) => {
  42.     return {
  43.         cor:state.cores.cor
  44.     };
  45. }
  46.  
  47. const Tela1Connect = connect(mapStateToProps, { trocarCor })(Tela1);
  48. export default Tela1Connect;
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