이제 setUser를 총 세 가지 시점에 호출해야 하는데, 호출되는 시점은 다음과 같습니다.
1. 프로필이 등록된 계정으로 로그인했을 때
2. Welcome 화면에서 프로필 정보를 등록했을 때
3. 앱을 새로 켜서 로그인 상태가 유지됐을 때
3번은 회원가입 기능을 완전히 마무리한 뒤 처리하기로 하고, 우선은 1번과 2번을 처리하겠습니다.
SignInScreen부터 수정해줍시다.
screens/SignInScreen.js
() import {useUserContext} from '../contexts/UserContext'; function ({navigation, route}) { const {isSignUp} route.params {}; const [form, setForm] ({ email: '', password: '', confirmPassword: '', }); const [loading, setLoading] (); const {setUser} = useUserContext(); const (name) => (value) => { ({form, [name] value}); }; const async () => { () try { const {user} isSignUp await (info) await (info); const profile await (user.uid); if (profile) { navigation.('Welcome', {uid: user.uid}); } else { setUser(profile); } ()