-
Notifications
You must be signed in to change notification settings - Fork 230
/
index.tsx
52 lines (41 loc) · 1.07 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { ApolloProvider } from '@apollo/client'
import { NextPageContext } from 'next'
import * as React from 'react'
import { useApollo } from '~/lib/apollo'
import { FathomProvider } from './Fathom'
import { SEO } from './SEO'
import { Toast } from './Toaster'
interface Props {
children?: any
pageProps: NextPageContext
}
const globalNavigationContext = {
isOpen: false,
setIsOpen: (val: boolean) => {},
}
export const GlobalNavigationContext = React.createContext(
globalNavigationContext
)
export function Providers({ children, pageProps }: Props) {
const apolloClient = useApollo(pageProps)
const initialState = {
isOpen: false,
setIsOpen,
}
const [state, setState] = React.useState(initialState)
function setIsOpen(isOpen) {
return setState({ ...state, isOpen })
}
return (
<>
<SEO />
<FathomProvider />
<Toast />
<ApolloProvider client={apolloClient}>
<GlobalNavigationContext.Provider value={state}>
{children}
</GlobalNavigationContext.Provider>
</ApolloProvider>
</>
)
}