diff --git a/src/App.tsx b/src/App.tsx
index f34c74e..bd1cb28 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,11 +1,11 @@
import { useContext, useMemo } from "react";
-import { AuthStateContext } from "./contexts/auth-state/AuthStateContext";
+import { AuthContext } from "./contexts/auth-state/AuthContext";
import LoginButton from "./components/LoginButton";
import Chat from "./components/Chat";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
export default function App() {
- const authContext = useContext(AuthStateContext);
+ const { authState } = useContext(AuthContext);
const queryClient = useMemo(
() =>
new QueryClient({
@@ -14,19 +14,13 @@ export default function App() {
[]
);
- if (!authContext) {
- return
Missing AuthStateContext provider?
;
- }
-
return (
<>
- {authContext.authState && (
+ {authState && (
-
- Hello: {authContext.authState.user.login}
-
+ Hello: {authState.user.login}
Chat Messages:
diff --git a/src/components/BadgeList.tsx b/src/components/BadgeList.tsx
index 1fc0b57..e917032 100644
--- a/src/components/BadgeList.tsx
+++ b/src/components/BadgeList.tsx
@@ -20,7 +20,7 @@ export default function BadgeList({
}: Props): React.ReactElement | undefined {
const twitchBadges = useContext(TwitchBadgeConext);
- if (!twitchBadges || badges.length === 0) {
+ if (badges.length === 0) {
return;
}
diff --git a/src/components/LoginButton.tsx b/src/components/LoginButton.tsx
index 48a0259..50315be 100644
--- a/src/components/LoginButton.tsx
+++ b/src/components/LoginButton.tsx
@@ -1,22 +1,18 @@
import { useContext } from "react";
-import { AuthStateContext } from "../contexts/auth-state/AuthStateContext";
+import { AuthContext } from "../contexts/auth-state/AuthContext";
export default function LoginButton(): React.ReactElement {
- const context = useContext(AuthStateContext);
+ const { authState, login, signOut } = useContext(AuthContext);
- if (!context) {
- throw new Error("LoginButton: Missing AuthStateContext");
- }
-
- if (context.authState) {
+ if (authState) {
return (
-