Auth.js
2.81 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import React, {useState, useEffect} from 'react';
import {ScrollView} from 'react-native';
import LoginComponent from "../components/Auth/LoginComponent";
import SignUpComponent from "../components/Auth/SignUpComponent";
import {useSelector} from "react-redux";
import {BUTTON_COLOR} from "../constant";
import SquareButtonComponent from "../components/Base/SquareButtonComponent";
const Auth = (props) => {
// 데이터
const {navigation} = props;
const [tryLogin, setTryLogin] = useState(true);
const {me} = useSelector(state => state.user);
// 함수
const changeTryLogin = () => {
setTryLogin(prev => !prev)
};
// 렌더링
useEffect(() => {
if (me) {
navigation.navigate('마이페이지');
}
}, [me]);
return (
<ScrollView>
{
tryLogin
?
<>
<LoginComponent/>
<SquareButtonComponent
onPress={changeTryLogin}
text={'회원가입'}
style1={{
marginLeft: 20,
marginRight: 20,
marginTop: 10,
marginBottom: 10,
padding: 15,
borderRadius: 3,
backgroundColor: BUTTON_COLOR
}}
style2={{
fontSize: 16,
fontWeight: 'bold',
textAlign: 'center',
color: '#ffffff'
}}
/>
</>
:
<>
<SignUpComponent/>
<SquareButtonComponent
onPress={changeTryLogin}
text={'로그인'}
style1={{
marginLeft: 20,
marginRight: 20,
marginTop: 10,
marginBottom: 10,
padding: 15,
borderRadius: 3,
backgroundColor: BUTTON_COLOR
}}
style2={{
fontSize: 16,
fontWeight: 'bold',
textAlign: 'center',
color: '#ffffff'
}}
/>
</>
}
</ScrollView>
)
};
export default Auth;