Skip to content

Commit 83817f6

Browse files
committed
Initialize state via callback function
1 parent 9aace77 commit 83817f6

File tree

1 file changed

+3
-5
lines changed
  • packages/homepage/src/components/Toast

1 file changed

+3
-5
lines changed

packages/homepage/src/components/Toast/index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
/* eslint-disable jsx-a11y/control-has-associated-label */
21
import React, { useState, useEffect } from 'react';
32
import { Link } from 'gatsby';
43
import { AnimatePresence } from 'framer-motion';
54

65
import { ToastContainer } from './elements';
76

7+
const key = 'ACCEPTED_TERMS_CODESANDBOX';
88
const Privacy = () => {
9-
const key = 'ACCEPTED_TERMS_CODESANDBOX';
10-
const [show, setShow] = useState(false);
9+
const [show, setShow] = useState(() => !window.localStorage.getItem(key));
1110

1211
useEffect(() => {
13-
setShow(!window.localStorage.getItem(key));
1412
window.localStorage.setItem(key, true);
1513
}, []);
1614

@@ -27,7 +25,7 @@ const Privacy = () => {
2725
<Link to="/legal/privacy">Privacy Policy</Link>
2826
<button
2927
type="button"
30-
ariaLabel="Close"
28+
aria-label="Close"
3129
onClick={() => setShow(false)}
3230
/>
3331
</ToastContainer>

0 commit comments

Comments
 (0)