Skip to content

Commit

Permalink
Patch LocalStorage Access from Server Component
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed Feb 26, 2024
1 parent 9943b5b commit c3543ac
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/POAPModal/POAPModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const event_names = {

const STORAGE_NAME_KEY = 'ens-page-default-mint';

const LocalStorage =
// eslint-disable-next-line no-undef
typeof window !== 'undefined' ? window.localStorage : undefined;

export const POAPModal: FC<{
data: IYKReferenceResponse;
name: string;
Expand All @@ -41,7 +45,7 @@ export const POAPModal: FC<{
const [hasRendered, setHasRendered] = useState(false);
const [mintToProfile, setMintToProfile] = useState(
// eslint-disable-next-line no-undef
localStorage?.getItem(STORAGE_NAME_KEY) || ''
LocalStorage?.getItem(STORAGE_NAME_KEY) || ''
);
const [mintToProfileError, setMintToProfileError] = useState<unknown>();

Expand Down Expand Up @@ -123,7 +127,7 @@ export const POAPModal: FC<{
onCallChange={() => {
setMintToProfile('');
// eslint-disable-next-line no-undef
localStorage?.setItem(STORAGE_NAME_KEY, '');
LocalStorage?.setItem(STORAGE_NAME_KEY, '');
}}
onCallClose={() => {
setDismissed(true);
Expand All @@ -138,7 +142,7 @@ export const POAPModal: FC<{
onSubmit={(name) => {
setMintToProfile(name);
// eslint-disable-next-line no-undef
localStorage?.setItem(
LocalStorage?.setItem(
STORAGE_NAME_KEY,
name
);
Expand Down

0 comments on commit c3543ac

Please sign in to comment.