Skip to content

Fix footer React hydration error #1799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Link } from 'gatsby';
import { useIsFirstRender } from '../hooks';

import cn from 'classnames';

Expand All @@ -25,6 +26,9 @@ const externalLink = {
};

const Footer = () => {
const isFirstRender = useIsFirstRender();
const currentYear = isFirstRender ? undefined : new Date().getFullYear();

return (
<footer className={cn(cols, css.root)}>
<div className={css.logoMobile}>
Expand Down Expand Up @@ -215,8 +219,8 @@ const Footer = () => {

<div className={css.copyright}>
<span>
2016-{new Date().getFullYear()} The Coding Train. All rights reserved.
Built in collaboration with{' '}
2016-{currentYear} The Coding Train. All rights reserved. Built in
collaboration with{' '}
<a href="https://designsystems.international/" {...externalLink}>
Design System International
</a>
Expand Down
Loading