実現したいこと
- FirebaseのAuthenticationを使用し、メールアドレスとパスワードを登録したい
前提
簡単なWebページを作成しています。
ユーザー登録のページを作成するのに、FirebaseのAuthenticationを用いてメールアドレスとパスワードを登録する機能を追加します。
発生している問題・エラーメッセージ
「createUserWithEmailAndPassword」を使用して、ボタンを押したらメールアドレスとパスワードをFirebaseに保存するコードを書きました。 コンソールにエラーは出ませんが、Firebaseにメールアドレスとパスワードが登録されません。 Firebaseのメールアドレスとパスワードの認証は有効にしています。
該当のソースコード
SignUp.jsx
import signupStyle from "./signup.module.css" import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; const SignUp = () => { const handleSubmit = (event) => { event.preventDefault(); const { email, password } = event.target.elements; const auth = getAuth(); createUserWithEmailAndPassword(auth, email, password) .then((userCredential) => { // Signed in const user = userCredential.user; }) .catch((error) => { const errorCode = error.code; const errorMessage = error.message; }); }; return ( <div className={signupStyle.container}> <h2>新規登録</h2> <form className={signupStyle.signup} onSubmit={handleSubmit}> <div> {/* <label>メールアドレス</label> */} <input name="email" type="email" placeholder="email" /> </div> <div> {/* <label>パスワード</label> */} <input name="password" type="password" placeholder="password" /> </div> <div> <button className={signupStyle.signup_btn} >登録</button> </div> </form> </div> ) } export default SignUp;
Firebase.js
import { initializeApp } from "firebase/app"; import { getFirestore } from "firebase/firestore"; import { getAuth } from "firebase/auth"; const firebaseConfig = { apiKey: "AIzaSyDILyh1IjjV4SKipvEZA5aZnnHU4-BjC8A", authDomain: "react9-77eeb.firebaseapp.com", projectId: "react9-77eeb", storageBucket: "react9-77eeb.appspot.com", messagingSenderId: "306334895626", appId: "1:306334895626:web:29f72faf55dd303cebd9f3", measurementId: "G-PB6QFEBK89" }; const app = initializeApp(firebaseConfig); const db = getFirestore(app); const auth = getAuth(app); export { auth }; export default db;
試したこと
Firebase公式のドキュメントを参考にしてみましたが、解決方法が分かりません。
補足情報
React/Reduxを使用しています。
初心者で勉強中です。
ご教授いただけると幸いです。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。