Skip to content

Commit

Permalink
feat: wrapp App #190
Browse files Browse the repository at this point in the history
  • Loading branch information
Храмыцких Антон committed Aug 23, 2023
1 parent cd16363 commit d2e56c1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
9 changes: 5 additions & 4 deletions components/GameResult/GameResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ import { BlockPayedGame, CustomButton, PurpleIcon, WhiteIcon } from 'components/
import { ScoreCard } from 'components/GameResult/ScoreCard/index';
import { TeamMemberBasic } from 'components/shared/ui/TeamMemberBasic';
import { OIcon, XIcon } from 'components/shared/ui/XOIcons';
import {useContext, useEffect, useState} from 'react';
import { useEffect, useState } from 'react';
import { FinishedGameState } from 'gameApi';
import {GameStateContext, IGameStateContext,} from "../../contexts/GameStateContext";
import {IGameStateContext, useGameStateContext} from "../../contexts/GameStateContext";
export const GameResult= () => {
const [countContextFinishResult, setCountContextFinishResult] = useState(0);
const { finishResult } = useContext(GameStateContext);
const gameStateContext = useGameStateContext();
const { finishResult } = gameStateContext;

useEffect(() => {
setCountContextFinishResult(prevCount => prevCount + 1);
}, [finishResult]);

console.log('Контекст в компоненте GameResult:', GameStateContext);
console.log('Контекст в компоненте GameResult:', gameStateContext);
console.log('Данные из контекста в GameResult:', finishResult);
console.log('Счетчик обновлений данных:', countContextFinishResult);

Expand Down
2 changes: 1 addition & 1 deletion contexts/GameStateContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const GameStateContextProvider: React.FC<{ children: React.ReactNode }> =

return <GameStateContext.Provider value={contextValue}>{children}</GameStateContext.Provider>;
}
// export const useGameStateContext = () => useContext(GameStateContext);
export const useGameStateContext = () => useContext(GameStateContext);

// export interface IGameStateContext {
// finishGameCheckResult: null | { winner: boolean; isDraw: boolean; cheatWin: boolean };
Expand Down
22 changes: 11 additions & 11 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import XmtpProvider from '../contexts/XmtpProvider';
// TODO: don't forget to bring back alchemy instead of publicProvider. @habdevs #190
// import {alchemyProvider} from 'wagmi/providers/alchemy';
import {GameStateContextProvider} from 'contexts/GameStateContext';
import { publicProvider } from 'wagmi/providers/public';
import {publicProvider} from 'wagmi/providers/public';

const {chains, provider, webSocketProvider} = configureChains(
[polygon],
Expand Down Expand Up @@ -47,11 +47,11 @@ function MyApp({Component, pageProps}: AppProps) {
return (
<WagmiConfig client={wagmiClient}>
<ApolloProvider client={client}>
<GameStateContextProvider>
<WalletContextProvider>
<XmtpContextProvider>
<RainbowKitProvider chains={chains}>
<XmtpProvider>
<WalletContextProvider>
<XmtpContextProvider>
<RainbowKitProvider chains={chains}>
<XmtpProvider>
<GameStateContextProvider>
<Layout version={version}>
<Head>
<meta
Expand All @@ -61,11 +61,11 @@ function MyApp({Component, pageProps}: AppProps) {
</Head>
<Component {...props} />
</Layout>
</XmtpProvider>
</RainbowKitProvider>
</XmtpContextProvider>
</WalletContextProvider>
</GameStateContextProvider>
</GameStateContextProvider>
</XmtpProvider>
</RainbowKitProvider>
</XmtpContextProvider>
</WalletContextProvider>
</ApolloProvider>
</WagmiConfig>
);
Expand Down

0 comments on commit d2e56c1

Please sign in to comment.