Skip to content

Commit

Permalink
refactor or ssr
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodDayForSurf committed Aug 27, 2024
1 parent 691b1fe commit 853070e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/dx-site/src/components/banner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import styles from './banner.module.scss';

const SHOW_BANNER_KEY = 'dx-show-banner';

let storage = { getItem: () => undefined, setItem: () => undefined };
try {
// eslint-disable-next-line no-undef
storage = window.localStorage;
} catch (e) {} // eslint-disable-line no-empty

const Banner = () => {
const [show, setShow] = React.useState(() => {
// eslint-disable-next-line no-undef
const showBanner = localStorage.getItem(SHOW_BANNER_KEY);
const showBanner = storage.getItem(SHOW_BANNER_KEY);
return showBanner !== '0';
});

Expand Down

0 comments on commit 853070e

Please sign in to comment.