Skip to content

Commit

Permalink
fix: context #190
Browse files Browse the repository at this point in the history
  • Loading branch information
Храмыцких Антон committed Aug 18, 2023
1 parent f8beb05 commit a8d40af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
18 changes: 7 additions & 11 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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 (
<ReferenceDataContextProvider>

<WagmiConfig client={wagmiClient}>
<ApolloProvider client={client}>
<WalletContextProvider>
Expand All @@ -65,15 +59,17 @@ function MyApp({ Component, pageProps }: AppProps) {
content="width=device-width, initial-scale=1"
/>
</Head>
<ReferenceDataContextProvider>
<Component {...props} />
</ReferenceDataContextProvider>
</Layout>
</XmtpProvider>
</RainbowKitProvider>
</XmtpContextProvider>
</WalletContextProvider>
</ApolloProvider>
</WagmiConfig>
</ReferenceDataContextProvider>

);
}

Expand Down
11 changes: 7 additions & 4 deletions pages/games/[gameType].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -641,19 +641,21 @@ const Game: NextPage<IGamePageProps> = ({gameType, version}) => {
);
}
}

interface IReferenceDataContextProvider {
children: ReactNode
}
const ReferenceDataContext = createContext({ finishGameCheckResult, finishedGameState });


const ReferenceDataContext = createContext({finishGameCheckResult, finishedGameState});

const ReferenceDataContextProvider: React.FC<IReferenceDataContextProvider> = ({children}) => {
return (
<ReferenceDataContext.Provider value={{ finishGameCheckResult, finishedGameState}}>
<ReferenceDataContext.Provider value={{finishGameCheckResult, finishedGameState}}>
{children}
</ReferenceDataContext.Provider>
)
}

console.log('REFERENCE CONTEXT', finishedGameState, finishGameCheckResult)

return <div>Loading...</div>;
Expand All @@ -678,3 +680,4 @@ export const getStaticPaths: GetStaticPaths<IParams> = () => {
};

export default Game;

0 comments on commit a8d40af

Please sign in to comment.