-
Notifications
You must be signed in to change notification settings - Fork 0
/
Seleccion.js
55 lines (47 loc) · 1.43 KB
/
Seleccion.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import React, { Component } from 'react'
import { Text, View, StyleSheet } from 'react-native'
import {connect} from 'react-redux'
import {autentication} from './Store/Servicios/Firebase'
import { RutasAutenticadas } from './Componentes/Autenticados/RutasAutenticadas';
import { RutasNoAutenticadas } from './Componentes/NoAutenticados/RutasNoAutenticadas';
import { session_starts, session_finished } from './Store/ACTIONS';
class Seleccion extends Component {
componentDidMount(){
this.props.autenth();
}
render() {
return (
<View style={styles.container}>
{/* <RutasAutenticadas/> */}
{this.props.user? <RutasAutenticadas/> : <RutasNoAutenticadas/>}
{/* <RutasNoAutenticadas /> */}
</View>
)
}
}
const styles = StyleSheet.create({
container:{
flex:1
}
})
const mapStateToProps = state =>{
return{
user: state.reducerSession
}
}
const mapDispatchToProps = dispatch =>{
return {
autenth: () =>{
autentication.onAuthStateChanged(function(user) {
if (user) {
console.log(user.toJSON());
dispatch(session_starts(user));
} else {
console.log('No existe la sesión');
dispatch(session_finished());
}
});
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(Seleccion);