Skip to content

Commit 8493d3c

Browse files
aleksandra.zagorskaaleksandra.zagorska
aleksandra.zagorska
authored and
aleksandra.zagorska
committed
Try to fix hydration error
1 parent add04a2 commit 8493d3c

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

src/analytics/contextual-cookie-consent.tsx

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import CookieConsent from 'react-cookie-consent'
22
import { CookieConsentProps } from 'react-cookie-consent/dist/CookieConsent.props'
3-
import React, { createContext, PropsWithChildren, useContext, useMemo, useState } from 'react'
3+
import React, { createContext, PropsWithChildren, useContext, useEffect, useState } from 'react'
44
import { hasUserDecidedOnConsent } from './local-storage-constants'
55

66
const CookieConsentContext = createContext({
77
visibleByDefault: false,
8-
setVisibleByDefault(visible: boolean) {},
8+
setVisibleByDefault(visible: boolean) {
9+
}
910
})
1011

11-
export const CookieConsentContextWrapper: React.FC<PropsWithChildren<{ visibleByDefault?: boolean }>> = function ({
12-
children,
13-
visibleByDefault,
14-
}) {
12+
export const CookieConsentContextWrapper: React.FC<PropsWithChildren<{ visibleByDefault?: boolean }>> = function({
13+
children,
14+
visibleByDefault
15+
}) {
1516
const [visible, setVisible] = useState(() =>
1617
typeof visibleByDefault == 'boolean' ? visibleByDefault : !hasUserDecidedOnConsent()
1718
)
@@ -27,7 +28,7 @@ class VisibleCookieConsent extends CookieConsent {
2728
super(props)
2829
this.state = {
2930
...this.state,
30-
visible: true,
31+
visible: true
3132
}
3233
}
3334
}
@@ -37,9 +38,15 @@ export function useCookieConsentContext() {
3738
}
3839

3940
export const ContextualCookieConsent: React.FC<Partial<CookieConsentProps>> = props => {
41+
const [isClient, setIsClient] = useState(false)
42+
43+
useEffect(() => {
44+
setIsClient(true)
45+
}, [])
46+
4047
const configuration = useCookieConsentContext()
4148

4249
const Component = configuration.visibleByDefault ? VisibleCookieConsent : CookieConsent
4350

44-
return <Component {...props} />
51+
return isClient && <Component {...props} />
4552
}

src/layout/TopNavigation/Logo.tsx

-5
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import { Link } from 'gatsby'
88
export const Logo: React.FC = () => {
99
return (
1010
<Link to='/' className={styles.brand} aria-label='Go to home page' role={'navigation'}>
11-
<StaticImage
12-
alt={'Bright Inventions logo'}
13-
className={classNames(styles.logo, styles.small)}
14-
src='../../../static/images/b_logo_black.svg'
15-
/>
1611
<StaticImage
1712
alt={'Bright Inventions logo'}
1813
className={styles.logo}

src/pages/index.tsx

+2-13
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,16 @@ const BlockchainExperts = React.lazy(() => import('../components/home/Blockchain
1818
const HeroHeaderImages = React.lazy(() => import('../components/home/HeroHeaderImages'))
1919

2020
export default () => {
21-
const isSSR = typeof window === 'undefined'
22-
2321
return (
2422
<Page className='page-index'>
2523
<Script type='text/javascript' src={'https://widget.clutch.co/static/js/widget.js'} async={true} />
2624
<Header />
2725
<Achievements />
28-
{!isSSR && (
29-
<React.Suspense fallback={<div />}>
30-
<HeroHeaderImages />
31-
</React.Suspense>
32-
)}
26+
<HeroHeaderImages />
3327
<TechnologyTags />
3428
<OurServices />
3529
<Ebook />
36-
{!isSSR && (
37-
<React.Suspense fallback={<div />}>
38-
<BlockchainExperts />
39-
</React.Suspense>
40-
)}
41-
30+
<BlockchainExperts />
4231
<Projects isSelectedTag={false} />
4332
<Ratings />
4433
<PopularBlogPosts />

0 commit comments

Comments
 (0)