diff --git a/components/use-local-state.js b/components/use-local-state.js index 4b620bdc..c7da0541 100644 --- a/components/use-local-state.js +++ b/components/use-local-state.js @@ -1,12 +1,11 @@ -import { useCallback, useEffect, useState } from 'react' +import { SSR } from '@/lib/constants' +import { useCallback, useState } from 'react' export default function useLocalState (storageKey, initialValue = '') { - const [value, innerSetValue] = useState(initialValue) - - useEffect(() => { - const value = window.localStorage.getItem(storageKey) - innerSetValue(JSON.parse(value)) - }, [storageKey]) + const [value, innerSetValue] = useState( + initialValue || + (SSR ? null : JSON.parse(window.localStorage.getItem(storageKey))) + ) const setValue = useCallback((newValue) => { window.localStorage.setItem(storageKey, JSON.stringify(newValue)) diff --git a/components/wallet-buttonbar.js b/components/wallet-buttonbar.js new file mode 100644 index 00000000..2b807569 --- /dev/null +++ b/components/wallet-buttonbar.js @@ -0,0 +1,23 @@ +import { Button } from 'react-bootstrap' +import CancelButton from './cancel-button' +import { SubmitButton } from './form' + +export default function WalletButtonBar ({ + wallet, disable, + className, children, onDelete, onCancel, hasCancel = true, + createText = 'attach', deleteText = 'detach', editText = 'save' +}) { + return ( +
+
+ {wallet.isConfigured && + } + {children} +
+ {hasCancel && } + {wallet.isConfigured ? editText : createText} +
+
+
+ ) +} diff --git a/components/wallet-card.js b/components/wallet-card.js index f607e3ca..cd7211a1 100644 --- a/components/wallet-card.js +++ b/components/wallet-card.js @@ -1,10 +1,8 @@ -import { Badge, Button, Card } from 'react-bootstrap' +import { Badge, Card } from 'react-bootstrap' import styles from '@/styles/wallet.module.css' import Plug from '@/svgs/plug.svg' import Gear from '@/svgs/settings-5-fill.svg' import Link from 'next/link' -import CancelButton from './cancel-button' -import { SubmitButton } from './form' import { useWallet, Status } from './wallet' export function WalletCard ({ name, title, badges, status }) { @@ -51,23 +49,3 @@ export function WalletCard ({ name, title, badges, status }) { ) } - -export function WalletButtonBar ({ - wallet, disable, - className, children, onDelete, onCancel, hasCancel = true, - createText = 'attach', deleteText = 'detach', editText = 'save' -}) { - return ( -
-
- {wallet.isConfigured && - } - {children} -
- {hasCancel && } - {wallet.isConfigured ? editText : createText} -
-
-
- ) -} diff --git a/pages/settings/wallets/[wallet].js b/pages/settings/wallets/[wallet].js index 34bd13e8..02ffce9e 100644 --- a/pages/settings/wallets/[wallet].js +++ b/pages/settings/wallets/[wallet].js @@ -1,7 +1,6 @@ import { getGetServerSideProps } from '@/api/ssrApollo' import { Form, ClientInput, ClientCheckbox, PasswordInput } from '@/components/form' import { CenterLayout } from '@/components/layout' -import { WalletButtonBar } from '@/components/wallet-card' import { WalletSecurityBanner } from '@/components/banners' import { WalletLogs } from '@/components/wallet-logger' import { useToast } from '@/components/toast' @@ -10,6 +9,9 @@ import { useWallet, Status } from '@/components/wallet' import Info from '@/components/info' import Text from '@/components/text' import { AutowithdrawSettings } from '@/components/autowithdraw-shared' +import dynamic from 'next/dynamic' + +const WalletButtonBar = dynamic(() => import('@/components/wallet-buttonbar.js'), { ssr: false }) export const getServerSideProps = getGetServerSideProps({ authRequired: true })