lordjackson

Base Codigo Native Base - React Native

Aug 19th, 2020 (edited)
896
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import {
  3.   Container,
  4.   Header,
  5.   Content,
  6.   Card,
  7.   CardItem,
  8.   Body,
  9.   Text,
  10.   Button,
  11.   Form,
  12.   Item,
  13.   Input,
  14.   Label,
  15.   List,
  16.   ListItem,
  17.   Radio,
  18.   Right,
  19.   Left,
  20. } from 'native-base';
  21.  
  22. import { FlatList, TouchableOpacity } from 'react-native';
  23.  
  24. import { FontAwesome5 } from '@expo/vector-icons';
  25.  
  26. import * as firebase from 'firebase';
  27.  
  28. // Your web app's Firebase configuration
  29. var firebaseConfig = {
  30.   apiKey: 'AIzaSyApmI9dEQ0ZhXYdO0ofl3F7LuwfuuZ4Q-U',
  31.   authDomain: 'aulapdm2020-c43f0.firebaseapp.com',
  32.   databaseURL: 'https://aulapdm2020-c43f0.firebaseio.com',
  33.   projectId: 'aulapdm2020-c43f0',
  34.   storageBucket: 'aulapdm2020-c43f0.appspot.com',
  35.   messagingSenderId: '660803083439',
  36.   appId: '1:660803083439:web:2dde11a2a9086c372ec85a',
  37. };
  38. try {
  39.   // Initialize Firebase
  40.   firebase.initializeApp(firebaseConfig);
  41. } catch (e) {
  42.   console.log('O App recarregou');
  43. }
  44.  
  45. export default class BDFirebase extends Component {
  46.   constructor(props) {
  47.     super(props);
  48.     this.state = {
  49.       arrayUsuario: null,
  50.     };
  51.  
  52.     firebase
  53.       .database()
  54.       .ref('usuario/001')
  55.       .set({
  56.         nome: 'Jackson',
  57.         telefone: '84 98800-5500',
  58.         cpf: '000.555.000-50',
  59.       })
  60.       .then(() => {
  61.         console.log('Inserido!');
  62.       })
  63.       .catch((error) => {
  64.         console.log(error);
  65.       });
  66.   }
  67.  
  68.   render() {
  69.     const { route } = this.props;
  70.     const { nome } = route.params;
  71.  
  72.     return (
  73.       <Container>
  74.         <Content scrollEnabled={true}>
  75.           <Card>
  76.             <CardItem>
  77.               <Body>
  78.                 <Text>Bem vindo {nome}</Text>
  79.               </Body>
  80.             </CardItem>
  81.           </Card>
  82.         </Content>
  83.       </Container>
  84.     );
  85.   }
  86. }
  87.  
Add Comment
Please, Sign In to add comment