From a8d40af80cdc0da1f6d74512cf42356298decc9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A5=D1=80=D0=B0=D0=BC=D1=8B=D1=86=D0=BA=D0=B8=D1=85=20?= =?UTF-8?q?=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Fri, 18 Aug 2023 13:33:18 +0500 Subject: [PATCH] fix: context #190 --- pages/_app.tsx | 18 +++++++----------- pages/games/[gameType].tsx | 11 +++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/pages/_app.tsx b/pages/_app.tsx index cb39206..6045c63 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -5,18 +5,16 @@ import { configureChains, createClient, WagmiConfig } from 'wagmi'; import { polygon } from 'wagmi/chains'; import { ApolloProvider, ApolloClient, InMemoryCache } from '@apollo/client'; // import { publicProvider } from 'wagmi/providers/public'; - import { Layout } from 'components'; import { WalletContextProvider } from 'contexts/WalltetContext'; import { XmtpContextProvider } from 'contexts/XmtpContext'; import 'i18n/index'; - import '@rainbow-me/rainbowkit/styles.css'; import 'styles/globals.css'; import XmtpProvider from '../contexts/XmtpProvider'; - import { alchemyProvider } from 'wagmi/providers/alchemy'; -import {ReactNode} from "react"; +import {ReactNode, useContext} from "react"; +import {ReferenceDataContextProvider} from "./games/[gameType]" const { chains, provider, webSocketProvider } = configureChains( [polygon], @@ -43,15 +41,11 @@ const client = new ApolloClient({ const version = 'v1.2.38'; - -function ReferenceDataContextProvider(props: { children: React.ReactNode }) { - return null; -} - function MyApp({ Component, pageProps }: AppProps) { + const { finishGameCheckResult, finishedGameState } = useContext(ReferenceDataContext) const props = { ...pageProps, version }; return ( - + @@ -65,7 +59,9 @@ function MyApp({ Component, pageProps }: AppProps) { content="width=device-width, initial-scale=1" /> + + @@ -73,7 +69,7 @@ function MyApp({ Component, pageProps }: AppProps) { - + ); } diff --git a/pages/games/[gameType].tsx b/pages/games/[gameType].tsx index e1254ce..7e0a336 100644 --- a/pages/games/[gameType].tsx +++ b/pages/games/[gameType].tsx @@ -641,19 +641,21 @@ const Game: NextPage = ({gameType, version}) => { ); } } - + interface IReferenceDataContextProvider { children: ReactNode } - const ReferenceDataContext = createContext({ finishGameCheckResult, finishedGameState }); - + + const ReferenceDataContext = createContext({finishGameCheckResult, finishedGameState}); + const ReferenceDataContextProvider: React.FC = ({children}) => { return ( - + {children} ) } + console.log('REFERENCE CONTEXT', finishedGameState, finishGameCheckResult) return
Loading...
; @@ -678,3 +680,4 @@ export const getStaticPaths: GetStaticPaths = () => { }; export default Game; +