9장 채팅 어플리케이션의 src/utils/firebase.js의 코드는 아래와 같다.
import * as firebase from "firebase";
import config from "../../firebase.json";
const app = firebase.initializeApp(config);
const Auth = app.auth();
export const login = async ({ email, password }) => {
const { user } = await Auth.signInWithEmailAndPassword(email, password);
return user;
};
이렇게 실행하면 에러가 난다.
While trying to resolve module `firebase` from file.....
firebase 모듈을 찾았는데 뭐 어쩌구에서 안돼!
위에 signInWithEmailAndPassword 칠때 자동완성 안될 때부터 쎄했다 내가..ㅋㅋㅋㅋ
구글링해도 안나오길래 책의 저자인 김범준님이 올려주신 깃허브에 업데이트된게 있나 확인했더니 역시나..
파이어베이스 웹 SDK버전이 v8에서 모듈식 v9로 업데이트되면서 모듈화 어쩌고 되는데 쨌든 그것땜에 호환이 안되었던 것이다.
수정 코드는 아래와 같다.
import { initializeApp } from "firebase/app";
import { getAuth, signInWithEmailAndPassword } from "firebase/auth";
import config from "../../firebase.json";
import { getAnalytics } from "firebase/analytics";
export const app = initializeApp(config);
const auth = getAuth(app);
export const login = async ({ email, password }) => {
const { user } = await signInWithEmailAndPassword(auth, email, password);
return user;
};
그리고 파이어베이스 v9 업데이트 관련 문서는 요기 → https://firebase.google.com/docs/web/modular-upgrade
아유 잘된다!!!!!!!!!
반응형
'앱 개발' 카테고리의 다른 글
[RN] ScrollView와 FlatList의 차이점 (0) | 2022.10.12 |
---|---|
node_modules 폴더 관리자 권한 없이 삭제 방법 (0) | 2022.07.04 |
[react-native] 지역 선택 : select되면 함수로 state 변경해서 안내 글자 바꾸기 (0) | 2022.06.21 |
[react-native] NativeBase 설치 및 처음 시작하기 (0) | 2022.06.20 |
[react-native expo] 페이지 이동 기능 구현 (navigation, stackNavagator) (0) | 2022.06.15 |
댓글