Skip to content

Commit

Permalink
Fix sessionstorage bug on deploying
Browse files Browse the repository at this point in the history
  • Loading branch information
fadihanna123 committed Sep 17, 2024
1 parent 458b021 commit 5a22a91
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/containers/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
import React, { useEffect } from 'react';
import { toast } from 'react-toastify';
import { PixabayBaseURL, PixabayKey } from '../utils';
Expand Down Expand Up @@ -32,17 +33,15 @@ const App = () => {
useEffect(() => {
const lang = sessionStorage.getItem(sessionStorageKeys.Lang);

if (typeof lang !== 'undefined' && lang !== null) {
if (lang === '') {
dispatch(setLang('en'));
}

if (lang === null || undefined) {
sessionStorage.setItem(sessionStorageKeys.Lang, 'en');
}
if (lang === '') {
dispatch(setLang('en'));
}

dispatch(setLang(lang!));
if (!lang) {
sessionStorage.setItem(sessionStorageKeys.Lang, 'en');
}

dispatch(setLang(lang!));
}, []);

useEffect(() => {
Expand Down

0 comments on commit 5a22a91

Please sign in to comment.