-
Notifications
You must be signed in to change notification settings - Fork 1
/
gatsby-browser.js
36 lines (32 loc) · 1016 Bytes
/
gatsby-browser.js
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
import React from "react";
import Layout from "./src/templates/layout";
import { ThemeProvider, CSSReset } from "@chakra-ui/core";
import customTheme from "./theme/theme";
import { CartProvider } from "react-use-cart";
import "isomorphic-fetch";
import { GraphQLClient, ClientContext } from "graphql-hooks";
import StripeProvider from "./src/components/StripeProvider";
const randomCartId = () =>
Math.random()
.toString(36)
.substring(7);
const client = new GraphQLClient({
url: "/.netlify/functions/graphql",
});
export const wrapPageElement = ({ element, props }) => {
return <Layout {...props}>{element}</Layout>;
};
export const wrapRootElement = ({ element }) => {
return (
<ThemeProvider theme={customTheme}>
<StripeProvider>
<ClientContext.Provider value={client}>
<CartProvider id={randomCartId()}>
<CSSReset />
{element}
</CartProvider>
</ClientContext.Provider>
</StripeProvider>
</ThemeProvider>
);
};