Skip to content

Commit

Permalink
fix: next hydration
Browse files Browse the repository at this point in the history
  • Loading branch information
adamazad committed Jan 17, 2023
1 parent f27fdc3 commit 2244af8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"presets": ["next/babel"],
"plugins": [["styled-components", { "ssr": true }]]
"plugins": [["styled-components", { "ssr": true, "displayName": true }]]
}
29 changes: 16 additions & 13 deletions src/layout/AppWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from 'react';
import { PropsWithChildren, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import styled from 'styled-components';

Expand All @@ -12,23 +12,26 @@ import { FOOTER_HEIGHT, HEADER_HEIGHT, MEDIA_WIDTHS } from '../theme';
export function PageLayout({ children }: PropsWithChildren) {
const { chainId } = useRainbow();
const { t } = useTranslation(['common', 'landing']);
const [isNetworkSupported, setIsNetworkSupported] = useState(false);

useEffect(() => {
setIsNetworkSupported(ENV_SUPPORTED_CHAIN_IDS.includes(chainId as number));
}, [chainId]);

return (
<Container>
<Header />
<Content>
{(() => {
if (!ENV_SUPPORTED_CHAIN_IDS.includes(chainId as number))
return (
<ErrorContainer>
<Heading>{t('error.unsupportedNetwork')}</Heading>
<Heading type="sub" color="#000">
Please change your network by clicking the account button on the top right.
</Heading>
</ErrorContainer>
);
return children;
})()}
{isNetworkSupported ? (
children
) : (
<ErrorContainer>
<Heading>{t('error.unsupportedNetwork')}</Heading>
<Heading type="sub" color="#000">
Please change your network by clicking the account button on the top right.
</Heading>
</ErrorContainer>
)}
</Content>
<Footer />
</Container>
Expand Down

0 comments on commit 2244af8

Please sign in to comment.