Skip to content

Commit 164ac17

Browse files
committed
Fix footer React hydration error
1 parent f1588af commit 164ac17

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/components/Footer.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Link } from 'gatsby';
3+
import { useIsFirstRender } from '../hooks';
34

45
import cn from 'classnames';
56

@@ -25,6 +26,9 @@ const externalLink = {
2526
};
2627

2728
const Footer = () => {
29+
const isFirstRender = useIsFirstRender();
30+
const currentYear = isFirstRender ? undefined : new Date().getFullYear();
31+
2832
return (
2933
<footer className={cn(cols, css.root)}>
3034
<div className={css.logoMobile}>
@@ -215,8 +219,8 @@ const Footer = () => {
215219

216220
<div className={css.copyright}>
217221
<span>
218-
2016-{new Date().getFullYear()} The Coding Train. All rights reserved.
219-
Built in collaboration with{' '}
222+
2016-{currentYear} The Coding Train. All rights reserved. Built in
223+
collaboration with{' '}
220224
<a href="https://designsystems.international/" {...externalLink}>
221225
Design System International
222226
</a>

0 commit comments

Comments
 (0)