Skip to content

Commit

Permalink
load web3 stuff client-side only
Browse files Browse the repository at this point in the history
  • Loading branch information
kremalicious committed Aug 17, 2023
1 parent cc6549b commit bed3752
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
3 changes: 1 addition & 2 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,7 @@ export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] =
util: false,
crypto: false,
path: false,
url: false,
process: false
url: false
}
}
})
Expand Down
5 changes: 3 additions & 2 deletions src/components/molecules/Web3Donation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { ReactElement, useState } from 'react'
import { parseEther } from 'viem'
import { ConnectButton } from '@rainbow-me/rainbowkit'
import { useDebounce } from 'use-debounce'
import { parseEther } from 'viem'
import { usePrepareSendTransaction, useSendTransaction } from 'wagmi'
import { ConnectButton } from '@rainbow-me/rainbowkit'

import Alert, { getTransactionMessage } from './Alert'
import InputGroup from './InputGroup'
import * as styles from './index.module.css'
Expand Down
16 changes: 12 additions & 4 deletions src/pages/thanks.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, { ReactElement } from 'react'
import { HeadProps } from 'gatsby'
import { RainbowKitProvider } from '@rainbow-me/rainbowkit'
import { WagmiConfig } from 'wagmi'
import { RainbowKitProvider } from '@rainbow-me/rainbowkit'
import { chains, theme, wagmiConfig } from '../helpers/rainbowkit'
import Copy from '../components/atoms/Copy'
import Meta, { HeadMetaProps } from '../components/atoms/HeadMeta'
import Icon from '../components/atoms/Icon'
import Web3Donation from '../components/molecules/Web3Donation'
import { chains, theme, wagmiConfig } from '../helpers/rainbowkit'
import { useSiteMetadata } from '../hooks/useSiteMetadata'
import * as styles from './thanks.module.css'

const meta: Partial<HeadMetaProps> = {
title: `Say Thanks`
}

const Web3Donation = React.lazy(
() => import('../components/molecules/Web3Donation')
)

function Coin({ address, title }: { address: string; title: string }) {
return (
<div className={styles.coin}>
Expand All @@ -36,6 +39,7 @@ const BackButton = () => (
)

export default function Thanks(): ReactElement {
const isSSR = typeof window === 'undefined'
const { author } = useSiteMetadata()
const coins = Object.entries(author).filter(
([key]) => key === 'bitcoin' || key === 'ether'
Expand All @@ -50,7 +54,11 @@ export default function Thanks(): ReactElement {

<WagmiConfig config={wagmiConfig}>
<RainbowKitProvider chains={chains} theme={theme}>
<Web3Donation address={author.ether} />
{!isSSR && (
<React.Suspense fallback={<div />}>
<Web3Donation address={author.ether} />
</React.Suspense>
)}
</RainbowKitProvider>
</WagmiConfig>

Expand Down

0 comments on commit bed3752

Please sign in to comment.