diff --git a/src/App.tsx b/src/App.tsx index 1e54a3f..72e1e99 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,3 @@ -import "currency-flags/dist/currency-flags.css"; import { FunctionComponent, useEffect, useReducer, useState } from "react"; import { BalanceContainer } from "./components/BalanceContainer"; import { ShortcutsContainer } from "./components/ShortcutsContainer"; diff --git a/src/index.tsx b/src/index.tsx index f4e9aef..24672de 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,8 +1,10 @@ import { StrictMode } from "react"; import { render } from "react-dom"; -import "./index.scss"; import { App } from "./App"; +import "./index.scss"; +import "currency-flags/dist/currency-flags.css"; + render( diff --git a/src/util/LocalStorageHelper.ts b/src/util/LocalStorageHelper.ts index c445136..da502cc 100644 --- a/src/util/LocalStorageHelper.ts +++ b/src/util/LocalStorageHelper.ts @@ -5,16 +5,20 @@ export enum LocalStorageKey { DISPLAYED_BALANCES = "displayedBalances", } -export const getFromLocalStorage = (key: LocalStorageKey, defaultValue: string | (() => string) = ""): string => { +export function getFromLocalStorage(key: LocalStorageKey): string | undefined; +export function getFromLocalStorage(key: LocalStorageKey, defaultValue: string): string; +export function getFromLocalStorage(key: LocalStorageKey, defaultValue?: string): string | undefined { let value = localStorage.getItem(key); - if (value === null) { - if (typeof defaultValue === "string") { - return defaultValue; - } - return defaultValue(); + if (value) { + return value; } - return value; -}; + + if (typeof defaultValue === "string") { + return defaultValue; + } + + return undefined; +} export const setLocalStorage = (key: LocalStorageKey, value: string) => { localStorage.setItem(key, value);