Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirebaseUIを使ってログイン周りを作成 #1

Merged
merged 9 commits into from
May 8, 2022

Conversation

tsubasa1122
Copy link
Owner

No description provided.

Comment on lines +19 to +20
"react": "17.0.2",
"react-dom": "17.0.2",
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 react18にするとfirebaseuiでエラーになるため、バージョンを下げることにした

ref: firebase/firebaseui-web-react#172

Copy link

@sushidesu sushidesu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

良さそうです 👍 👍

Comment on lines +7 to +13
export type AuthState = {
isSignedIn: boolean;
isLoading: boolean;
userId: string | undefined;
userName: string | undefined;
idToken: string | undefined;
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こういう書き方もあるかな〜と思いました! 🙌

type AuthState = {
  type: "signedIn"
  userId: string
  userName: string
  idToken: string
} | {
  type: "loading"
} | {
  type: "notSignedIn"
}

type: "signedIn" のときだけ userId , userName , idToken があると推論されるので、使う側が本来必要のないundefinedのチェックをしなくて良くなる という利点があります!

フラグが複数あると複雑なので ステート で表現したい、というのもあります 👀

@tsubasa1122 tsubasa1122 merged commit 9bf3c0f into main May 8, 2022
@tsubasa1122 tsubasa1122 deleted the setup-authentication branch May 8, 2022 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants