Skip to content

Commit a56dbee

Browse files
authored
Merge pull request #191 from carbonplan/Shane98c/footer-year
fix hydration errors on new years
2 parents 3210e1a + 54f0c87 commit a56dbee

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/footer.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import React from 'react'
1+
import React, { useState, useEffect } from 'react'
22
import { Box, Flex, Link } from 'theme-ui'
33
import { default as NextLink } from 'next/link'
44
import Monogram from './monogram'
55
import Row from './row'
66
import Column from './column'
77

8-
const getCurrentYear = () => new Date().getFullYear()
9-
108
const Footer = () => {
9+
const [year, setYear] = useState(null)
10+
useEffect(() => {
11+
setYear(new Date().getFullYear())
12+
}, [])
13+
1114
return (
1215
<Box
1316
sx={{
@@ -128,7 +131,7 @@ const Footer = () => {
128131
gap: [0, 0, '10px', '12px'],
129132
}}
130133
>
131-
<Box>(c) {getCurrentYear()}</Box>
134+
<Box>(c) {year}</Box>
132135
<Box>CARBONPLAN</Box>
133136
</Flex>
134137
</Box>

0 commit comments

Comments
 (0)