aboutsummaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
Diffstat (limited to 'pages')
-rw-r--r--pages/_app.tsx5
-rw-r--r--pages/index.tsx8
2 files changed, 11 insertions, 2 deletions
diff --git a/pages/_app.tsx b/pages/_app.tsx
index 1561eda..bfde0d7 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -1,6 +1,7 @@
import Head from 'next/head';
import { PreferencesContextWrapper } from '../components/preferencesContext';
import { ToastContextWrapper } from '../components/toast';
+import { SocketContextWrapper } from '../components/socketContext';
import '../styles/global.css';
import '../styles/dark.css';
@@ -26,7 +27,9 @@ export default function VierOpEenRijWebsite({ Component, pageProps }) {
</Head>
<PreferencesContextWrapper>
<ToastContextWrapper>
- <Component {...pageProps}/>
+ <SocketContextWrapper>
+ <Component {...pageProps}/>
+ </SocketContextWrapper>
</ToastContextWrapper>
</PreferencesContextWrapper>
</div>
diff --git a/pages/index.tsx b/pages/index.tsx
index 266a3f4..dfb14e6 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -1,6 +1,7 @@
-import { CSSProperties, useState, useEffect } from 'react';
+import { CSSProperties, useState, useEffect, useContext } from 'react';
import axios from 'axios';
import { userInfo, userGameTotals, userGames } from '../api/api';
+import { SocketContext } from '../components/socketContext';
import { NavBar } from '../components/navbar';
import { CenteredPage, PageTitle } from '../components/page';
@@ -120,6 +121,11 @@ export default function HomePage() {
var server = typeof window === "undefined";
var loggedIn = !server && document.cookie.includes("token");
+ var { io } = useContext(SocketContext);
+ useEffect(() => {
+ io.on("connect", () => { console.log("gert") });
+ }, []);
+
var [userInfo, setUserInfo] = useState<userInfo>();
var [gameInfo, setGameInfo] = useState<userGames>();